orangebloss
Board Regular
- Joined
- Jun 5, 2013
- Messages
- 51
- Office Version
- 365
- Platform
- Windows
Hi there
I have a work book that needs to be saved by default in the folder it was opened but users should be able to move it as required using Save As.
At the moment I'm getting complaints that the Save As windows opens on a local folder on the users computer rather than the network folder they opened it in.
I've spent hours googling and searching and can find some solutions but none which quite hit the mark.
In short on Save the code should check 'Save As' was used and if not it brings up the save as dialogue box in the folder that the file currently sits in. The user can then decide whether it needs to be in a different folder.
Coding I have so far brings up the Save As box :
Any suggestions how I can incorporate the file path (assume that the network drive mapping is different for each user)?
I have a work book that needs to be saved by default in the folder it was opened but users should be able to move it as required using Save As.
At the moment I'm getting complaints that the Save As windows opens on a local folder on the users computer rather than the network folder they opened it in.
I've spent hours googling and searching and can find some solutions but none which quite hit the mark.
In short on Save the code should check 'Save As' was used and if not it brings up the save as dialogue box in the folder that the file currently sits in. The user can then decide whether it needs to be in a different folder.
Coding I have so far brings up the Save As box :
Code:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Dim txtFileName As String
If SaveAsUI = False Then
Cancel = True
MsgBox "You cannot save this workbook. Use Save As"
End If
'2. Call up your own dialog box. Cancel out if user Cancels in the dialog box.
'ThisWorkbook.Path & "\" &
txtFileName = Application.GetSaveAsFilename(, "Excel Macro-Enabled Workbook (*.xlsm), *.xlsm", , "Save As XLSM file")
If txtFileName = "False" Then
MsgBox "Action Cancelled", vbOKOnly
Cancel = True
Exit Sub
End If
'3. Save the file.
Application.EnableEvents = False
ThisWorkbook.SaveAs Filename:=txtFileName, FileFormat:=xlOpenXMLWorkbookMacroEnabled
Application.EnableEvents = True
End Sub
Any suggestions how I can incorporate the file path (assume that the network drive mapping is different for each user)?