opening a word document from project

S

Steff

Next Question on this journey...

I am trying to open a document from a master document list and then save it
using the name that the user inputs. Here is my code


Private Sub CommandButton1_Click()

'Create A Package

Dim WordApp As Word.Application
Dim strPacName As String
Dim Count As Long
Dim NewPac As Long
strPacName = InputBox("Equipment Name", "Package Creation", , , ,
"c:\Windows\Help\Procedure Help.chm", 0)

If strPacName <> "" Then
Set WordApp = CreateObject("Word.Application")
WordApp.Visible = True
WordApp.Documents.Open "C:\Documents and
Settings\slilly\Desktop\Master Form Directory\Word Documents\Example
Package.doc", ReadOnly:=False
WordApp.ActiveDocument.SaveAs FileName:="C:\Documents and
Settings\slilly\Desktop\Blank Project\Word Files\" & strPacName & ".doc"

End If
Set WordApp = Nothing

End Sub

It opens the document but then it puts up an option box telling me that the
document is already in use and "do I want to open it in read only?"... Why oh
why does this program hate me so? If I select "read only", it saves it like
it is supposed to and it lets me edit it so it is a regular file... not read
only... any ideas on why it does this?
 
J

Jan De Messemaeker

Hi,

As far as I can see your sub does not close the file nor the Word
application (Wordapp.quit) so it is not abnomraml that a copy stays open.
 
S

Steff

Oh... the copy is supposed to stay open. When the project manager wants to
create a new engineering package, I tied a macro to a button that pulls open
a blank package from a master document list, he types in the name of the
system he is writing a package for, it then saves it as a package under the
system name he gives it, and then he can edit it at will. It does everything
I want it to except that when it opens the master document it first opens a
box that says "Example Package.doc is locked for editing by another user" and
then makes me choose to open it as read only. It should just open and allow
for editing.
 
J

Jan De Messemaeker

Hi,

Well, if it's open, and you open again, it proposes read only.
In the Word app, search for the open doculent rather than opening it.
HTH
 

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