No Filedialog message to say file already exists
The code below will look familiar to some!
(Controlling Word from Excel)
When saving, I do not get filediolog message saying file already exists, my code as it is just over writes/replaces the existing file if it is.
I have Googled my heart out and the chances are the answer was right in front of me. I have tested various methods all in different locations within the code. All come back saying file exists – but then it would do wouldn’t it because haven’t I just created it with the Template?
So it is a matter of where when and how do I place the argument for if it exists or not
It all really comes down the file dialog not showing?
Any help readily received.
'macropods version using a .dotx template
Dim wdApp As Word.Application
Dim wdDoc As Word.Document
Dim wdRng As Word.Range
Dim wdPath As String
wdPath = "C:\Users\Me\ Documents\My Doc\ServiceTimes\2014 Timesheets\"
ThisWorkbook.ActiveSheet.Range("B10:E59").Copy 'Range on Excel sheet of condensed Timesheets
Set wdApp = New Word.Application
Set wdDoc = wdApp.Documents.Open(wdPath & "Timesheets.dotx") ' Create a new document
'Populate the document
Set wdRng = .Bookmarks("Point_1").Range
.Bookmarks.Add "Point_1", wdRng
'Save the document
.SaveAs2 Filename:=wdPath & "Timesheets " & Format(Now, "(mmm)") & ".docx", _
.Visible = True
.ActiveWindow.WindowState = wdWindowStateNormal
.Left = 300
.Top = 15
.Width = 500
.Height = 600
Set wdDoc = Nothing: Set wdApp = Nothing