06-03-20 03:13 PM
Hi,
I am trying to pass some enumerations from Word VBA into a code stage using the Word VBO.
MS Word internal code is using some enumerations that are not recognised by VB code stages.
For example :
Dim doc as Object = GetDocument(Handle,documentname)
doc.MailMerge.OpenDataSource (DataSourceName, SQLStatement:="SELECT * FROM `ABC$`")
With doc.MailMerge
.Destination = wdSendToNewDocument
End With
Error message is wdSendToNewDocument is not declared. It may be inaccessible due to its protection level.
This issue only happen with enumerations starting by wd* (e.g : wdSendToNewDocument, wdDefaultFirstRecord , wdDefaultLastRecord etc..).
Enumerations starting by wd* are specific to Word VBA.
Is there a way to make these wd* work in a code stage ?
06-03-20 04:16 PM
Hi François,
I haven't tested the code but I tried to add the "Microsoft.Office.Interop.Word.dll" to the External References in the Code Options of the Initialise action, also I added the "Microsoft.Office.Interop.Word" namespace in the Namespace Imports list. Then I tried to use "WdMailMergeDestination.wdSendToNewDocument" to my code and the Check Code doesn't give any error. You might want to try, I can't guarantee it works!
You have to add the "Microsoft.Office.Interop.Word.dll" manually using the Browse button. In my case it was under a "C:\Windows\assembly\GAC_MSIL\Microsoft.Office.Interop.Word\15.0.0.0 ........" folder
09-03-20 07:56 PM