Hey all,
I am working on a way to automatic open a word document fill in some text and save, but the problem I am seeking an answer to is the following: "If the filename already exist my current code (See below) will overwrite the old file... BUT I want to keep both files, and eventually ad a uniq number to the new file, e.g. Doc(2).
I am trying to avoid userinteraction, so no prompt or msg boxes.
My code:
Sub Makro1()
Dim objWord As Object
Dim objDoc As Object
Set objWord = CreateObject("Word.Application")
Set objDoc = objWord.Documents.Add
objDoc.Saveas "C:\Users\MFM\Documents"
objDoc.Close
Set objDoc = Nothing
Set objWord = Nothing
End Sub
Question: How can I code so that the document will automatic saveas the two first words in the word document and if that filename already exist ad a (number) to the filename.
The default mode in using objdoc.saveas is that it overwrite if the filename exist, I want to NOT overwrite but to keep both files without asking the user.
Thank you