The code below forces a new, unsaved instance in Excel (opened from a sharepoint menu on our intranet) to save as a macro-enabled workbook, but I cannot get it to open the "Save As" window to the correct path.
The issue is when they save, it defaults to their local My Documents folder, but we want this to save to whatever sharepoint (web folder) they last navigated to when they opened the new instance. That is exactly the path it opens to if I remove this code, so it's in there somewhere.
(Without this code, although it wants to save in the correct web folder, it tries to save as an xlsx by default, which is a nuisance to the users...who are also unwilling to just change the type to xlsm in the save as dialog.)
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Dim varFileName As Variant
If SaveAsUI = True Then
Cancel = True
Application.EnableEvents = False
varFileName = Application.GetSaveAsFilename("somefilename.xlsm", " Excel Macro Enabled Workbook (*.xlsm), *.xlsm,", 2)
If varFileName = vbFalse Then
Cancel = True
Else
Me.SaveAs varFileName, 52
End If
Application.EnableEvents = True
End If
End Sub
Bookmarks