checking the filename of a word document using VB

dusty

Registered User.
Local time
Today, 10:20
Joined
Aug 20, 2009
Messages
42
At the moment I have a userform which loads on open.

Private Sub Document_Open()
UserForm1.Show
End Sub

the document is read only so when saved a copy will be made under a new filename.

I want to insert an if statement to the above to check if the file is the original or a copy so that a copied version will not show the userform but the original will.

Private Sub Document_Open()
if(what do i insert here to check if filename is the original) then
UserForm1.Show
Else
Userform1.Hide
End if
End Sub

This is what I want to achieve hope it is clear.

Cheers Dusty
 
Untested but you should be able to query the Me.Name property on the document open event

Code:
If Me.Name = "C:\Whatever the template is called.doc" Then
   Userform1.Show
Else
   UserForm1.Hide
End If

David
 
works great thanks
 

Users who are viewing this thread

Back
Top Bottom