I'm using DDE to send VB commands to Word to print all or selected pages of the current Word Document. If I invoke a Word Macro that does not require any values passed to it, it works fine. But, if the Word Macro requires a value to be passed to it (such as the range of pages to be printed) it fails.
These are the two Word Macros that I'm working with:
Sub prt_pgs_all()
' Print All Pages in Current Document
Application.PrintOut FileName:="", Range:=wdPrintAllDocument, Item:= _
wdPrintDocumentContent, Copies:=1, Pages:="", PageType:=wdPrintAllPages, _
ManualDuplexPrint:=False, Collate:=True, Background:=True, PrintToFile:= _
False, PrintZoomColumn:=0, PrintZoomRow:=0, PrintZoomPaperWidth:=0, _
PrintZoomPaperHeight:=0
End Sub
Sub prt_pgs_rng(stPg As String)
' Print a Range of Pages in Current Document
' "1-1" = Print Page 1
' "1-10" = Print First 10 pages
Application.PrintOut FileName:="", Range:=wdPrintRangeOfPages, Item:= _
wdPrintDocumentContent, Copies:=1, Pages:=stPg, PageType:=wdPrintAllPages, _
ManualDuplexPrint:=False, Collate:=True, Background:=True, PrintToFile:= _
False, PrintZoomColumn:=0, PrintZoomRow:=0, PrintZoomPaperWidth:=0, _
PrintZoomPaperHeight:=0
End Sub
To print all pages I send the following comand:
put '[call prt_pgs_all]'; - this works fine
To print only the first page I send the following command:
put '[call prt_pgs_rng ("1-1")]'; - this does not work
In Word I get a Compile error saying the Sub or Function is not Found and it displays the following code:
Private Sub TmpDDE
prt_pgs_rng__ ("1-1")
End Sub
Note the underscores appended to the macro name - not sure where they came from, but when I remove them and continue the Subroutine works.
If you can shed some light I'd appreciate it.