Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / May 2008

Tip: Looking for answers? Try searching our database.

Why does Application.Documents.Open show print dialog?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Michael - 29 May 2008 20:17 GMT
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
StevenM - 29 May 2008 21:20 GMT
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

> 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
[quoted text clipped - 7 lines]
>
> End Sub
Michael - 29 May 2008 21:31 GMT
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.

> To: Michael,
>
[quoted text clipped - 28 lines]
> >
> > End Sub
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.