Sub SaveFile()
Dim NameFile As String
With Worksheets("SO1")
NameFile = .Range("A1") & "_" & .Range("B1") & "_" & .Range("C1") & ".xls"
End With
ThisWorkbook.SaveAs Environ("USERPROFILE") & "\Desktop\tickets\" & NameFile
End Sub
Sub SaveFile()
Dim NameFile As String
With Worksheets("SO1")
NameFile = .Range("A1") & "_" & .Range("B1") & "_" & .Range("C1") & ".xls"
End With
NameFile = Application.GetSaveAsFilename(InitialFileName:=Environ("USERPROFILE") & "\Desktop\tickets\" & NameFile, Filefilter:="Fichier Excel (*.xls), *.xls")
If NameFile = False Then
MsgBox "File not saved"
Else
ThisWorkbook.SaveAs Filename:=NameFile
End If
End Sub
Sub SaveFile()
Dim NameFile As Variant
With Worksheets("SO1")
NameFile = .Range("M3") & "_" & .Range("C11") & "_" & .Range("B22") & ".xls"
End With
NameFile = Application.GetSaveAsFilename(InitialFileName:=Environ("USERPROFILE") & "\Desktop\tickets\" & NameFile, Filefilter:="Fichier Excel (*.xls), *.xls")
If NameFile = False Then
MsgBox "File not saved"
Else
ThisWorkbook.SaveAs Filename:=NameFile
End If
End Sub
Thread solved. The following code works for me.
Code:Sub SaveFile() Dim NameFile As Variant With Worksheets("SO1") NameFile = .Range("M3") & "_" & .Range("C11") & "_" & .Range("B22") & ".xls" End With NameFile = Application.GetSaveAsFilename(InitialFileName:=Environ("USERPROFILE") & "\Desktop\tickets\" & NameFile, Filefilter:="Fichier Excel (*.xls), *.xls") If NameFile = False Then MsgBox "File not saved" Else ThisWorkbook.SaveAs Filename:=NameFile End If End Sub
Sub test()
Application.Dialogs(xlDialogSaveAs).Show "myFileName"
End Sub
Sub test2()
If Application.Dialogs(xlDialogSaveAs).Show("otherName") Then
MsgBox "file was saved"
Else
MsgBox "file not saved"
End If
End Sub
Hi Ryan,
I was trying your above code, It works perfectly, but my criteria is little different from yours. I wanted to save the file in .pdf format. And the file should open publish, can you help me on this.
I tried replacing .xls to .pdf in the above code, the file gets created but it will not open after publish. Once I open the file from the saved location it throws an error as unsupported file & the file size is becoming too high (in MBs).
Many Thanks in advance.
Regards
Texitech