Save a worksheet with form Save As location in Excel VBA

两盒软妹~` 提交于 2020-01-06 18:10:11

问题


Well, I am not a developer but an regular an Excel user try to automate some process while working so please understand if my question is of simple to do.

I just want to a macro that can when I run the macro, it will allow me to Browse the computer so I can save the file in the direction and file name I like If possible Default location is the location of the workbook, just to save time

Thank you


回答1:


Try below code :

Sub SaveAsDailog()

Application.DisplayAlerts = False
Dim filePath As Variant
filePath = Application.GetSaveAsFilename("abcd.xlsx", "Excel Files (*.xlsx), *.xlsx")

If VarType(filePath) = vbString Then
 ActiveWorkbook.SaveAs Filename:=filePath
End If


Application.DisplayAlerts = True
End Sub


来源:https://stackoverflow.com/questions/15886130/save-a-worksheet-with-form-save-as-location-in-excel-vba

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!