Document Name and Location after Programmatic Open

R

rlm

When we attempt to programmatically open a document with a file spec
of "O:\Docs\Instructions\Corp\DocName.mhtml" with the code listed
below the the correct document is opened. The problem though is that
the document name (objDoc.Name) is "DocumentN" (i.e. Document1). Two
unwanted results are that the information displayed in the Word
titlebar is "DocumentN - Microsoft Word". Also, when moving through
the menu items File > Save As the File name displayed in the Save As
dialog "DocName.mht" and the Save In location is "My Documents". I
am
searching for a resource on the topic.


When I open the same document via Microsoft Word, through the
standard
user interface then all works as expected - "DocName - Microsoft
Word"
is displayed and Save As File name is "DocName.mhtml" and location
points to "O:\Docs\Instructions\Corp".


May I please have a bit of help?


doc2open = "O:\Docs\Instructions\Corp\DocName.mhtml"


Dim objWordApp As Word.Application
Dim objDoc As Word.Document


Set objWordApp = New Word.Application


Set objDoc = objWordApp.Documents.Add(doc2Open)


objWordApp.Visible = True
objWordApp.Activate
 
T

Tony Jollans

Documents.Add ... creates a new document. You need to use Documents.Open
.... to edit an existing document
 

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