I have working save as line for my VBA script in excel before and the file is saving to a network folder. Before, the server has name, now we access the server folders using an IP (192.168.20.212), hence I changed the address in code using the IP.
Now, the problem is that the file naming I set is not working. When the dialog box appears, the filename is empty and the user needs to manually enter the filename. However, if I put a server name or use local address, the file naming is working. I have no choice but use the IP to save file.
The following is the line for the file naming;
filenme = "PENDING CLAIMS_" + szNextDatereformat
And the following is the line for saving the file before;
Dim sFileSaveName As String
sFileSaveName = Application.GetSaveAsFilename _
(InitialFileName:="\\SERVERNAME\excel_files\" & filenme & sTargetFile, _
FileFilter:="Excel Files (*.xlsx), *.xlsx")
If sFileSaveName <> "False" Then
'-- Savethe file --
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs FileName:=sFileSaveName, _
FileFormat:=51
Application.DisplayAlerts = True
Else
'-- Popup message --
MsgBox "Template not saved!", vbExclamation, "Warning"
End If
The new one should be;
Dim sFileSaveName As String
sFileSaveName = Application.GetSaveAsFilename _
(InitialFileName:="\\192.168.20.212\excel_files\" & filenme & sTargetFile, _
FileFilter:="Excel Files (*.xlsx), *.xlsx")
If sFileSaveName <> "False" Then
'-- Savethe file --
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs FileName:=sFileSaveName, _
FileFormat:=51
Application.DisplayAlerts = True
Else
'-- Popup message --
MsgBox "Template not saved!", vbExclamation, "Warning"
End If