Why does Application.Documents.Open show print dialog?

M

Michael

Why does the following code executed from VBA in some host (e.g., Excel)
display the print dialog in Word on the open call? I would like to be able
to open the document in an invisible Word application. The VBA code does not
return from the open until the user dismisses the print dialog.

Sub Test
Dim WA as New Word.Application

WA.Documents.Open "C:\Path\File.rtf"

End Sub
 
S

StevenM

To: Michael,

Perhaps things are done differently in Excel, but from Word, you might try
something like:

Sub TestOpenDoc()
Dim sFileName As String
Dim newDoc As Document

sFileName = "C:\temp.txt"
If (Dir(sFileName) = "") Then
MsgBox "File does not exit."
Else
Set newDoc = Documents.Open(FileName:=sFileName, Visible:=False)
MsgBox "Click ok"
newDoc.Close
End If
End Sub

Steven Craig Miller
 
M

Michael

I can't open it from Word (or Excel for that matter). I need to open it in a
C++ application using COM out-of-process. However, I'm seeing the same
behavior in Excel (or any other VBA out-of-process client, e.g, Visio) as I
am in my C++ application. The code is going to be in C++ not VBA, and it
will run in a different process. I just used VBA as a sample since it is
simpler and exhibits the same behavior.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top