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 / December 2006

Tip: Looking for answers? Try searching our database.

Filename Test

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Leckie - 14 Dec 2006 00:22 GMT
New to vb macros - hope this isn't a stupid question - but can't seem to find
it.

I have a template that on closeing saves the file with a particular filename
(they all start with the same text) and protects the file with a password it
prompts you for.  My problem is when you reopen the file - it prompts and
resaves (of course).

I'd like to use an if-then statement to test the filename.  If it begins
with certain characters - I just want it to save and close the file.  I don't
know how to test the filename.  Help!

Thanks, in advance, for any help you can provide!
Greg Maxey - 14 Dec 2006 00:35 GMT
Leckie,

If a file has never been saved, then its filepath is null.  You could use
something like:

Sub Test()
If ActiveDocument.Path = vbNullString Then
 ActiveDocument.SaveAs "C:\Test.doc"
Else
 ActiveDocument.Save
End If
ActiveDocument.Close
End Sub

Signature

Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.

> New to vb macros - hope this isn't a stupid question - but can't seem to
> find
[quoted text clipped - 13 lines]
>
> Thanks, in advance, for any help you can provide!
 
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.