Lookup Word doc and then saveas new doc

craigachan

Registered User.
Local time
Today, 11:59
Joined
Nov 9, 2007
Messages
285
I've written code that creates word documents based on a word template, then names and saves the document with the filename = patientname & date. However sometimes a second letter may be written from another template but may accidentally overwrite the original word document with filename = Patientname and date (if they were written on the same date). Can someone tell me how to write code that looks up to see if the file name already exist, then if it does, filename = patientname & date &1 (or 2 or 3)? I remember seeing some code once that had percent char (%) in it that would automatically name a file. I'm not sure what it was or whether it applies her or not.

I would appreciate any help.
 
You can use the VBA function "Dir()" to find out if a file already exists. Look up the documentation in VBA Help for samples.
 
Thank you. I'll give that a try.
 

Users who are viewing this thread

Back
Top Bottom