I do a lot of writing on my laptop and want a quick way to save a copy of my current project to a thumb drive as backup. I wrote the code below to figure out the active file's folder then use that as part of the save path. That all works fine but when I get to the ActiveDocument.SaveAs2 the program always brings up the SaveAs dialogue and the location is on the laptop, not the thumb drive.
My code is below. Please help This 'simple' project has gotten me very frustrated.
Sub Backup()
' Macro to backup writing projects.
' Declare variables
Dim strSavePath, strFileName, strFolder As String
Dim intPathLength, intFolderLength As Integer
' Assign variables
strFileName = ActiveDocument.Name
intPathLength = Len(ActiveDocument.Path)
intFolderLength = intPathLength - 39
strFolder = Mid(ActiveDocument.Path, 40, intFolderLength)
' Construct save path
strSavePath = "D:\" & strFolder & "\" & strFileName
' Save backup file to thumb drive
Application.DisplayAlerts = wdAlertsNone
ActiveDocument.SaveAs2 FileName:=strSavePath, FileFormat:=wdFormatDocumentDefault
Application.DisplayAlerts = wdAlertsAll
End Sub