简体   繁体   中英

Excel VBA to save to specific folder (with current code generating filename)

workers,

I have this code at the moment;

Public Sub SaveAsA1()
    ActiveWorkbook.SaveAs Filename:=Range("P4").Value & ";" & Range("F6").Value & ";" & Range("R6").Value & ";" & Range("R4").Value
End Sub

Which i would like to modify to be saved in a certain filemap; \\S31000265\\Users$\\NR4236\\My Documents\\TV-01-project\\TestmapWeek9GOED. Been trying but it keeps overwriting the Filename-code. Hope you guys can help me out.

Public Sub SaveAsA1()
    ChDir ("C:\work\testout\") ' Directory you need to save the file as xlsm
    Filename = Range("P4").Value & ";" & Range("F6").Value & ";" & Range("R6").Value & ";" & Range("R4").Value
    ActiveWorkbook.SaveAs Filename:=Filename, FileFormat:=52
End Sub

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM