Hello excel help folks,
I am looking to write up something that pops up the save as dialog box, pulls the user name to be able to add to the path as to where the file will be saving. I was able to figure out the code to get it to work how I want on my computer specificialy but would like that path to pull in the current username so it can work on any computer for any user.
This is the code that I was able to get to work thus far.
I am looking to write up something that pops up the save as dialog box, pulls the user name to be able to add to the path as to where the file will be saving. I was able to figure out the code to get it to work how I want on my computer specificialy but would like that path to pull in the current username so it can work on any computer for any user.
This is the code that I was able to get to work thus far.
VBA Code:
Sub saveaswithlocation()
Dim file_name As Variant
Dim fName As String
ChDrive "C"
ChDir "C:\Users\[B][I]username[/I][/B]\Documents\Job Folders\" & Range("C2")
fName = Range("C2").Value & " - Offer Checklist - " & Range("C15").Value & " " & Range("C16").Value
' Get the file name.
file_name = Application.GetSaveAsFilename(fName, _
Filefilter:="Excel Macro-Enabled Workbook,*.xlsm,All Files,*.*", _
Title:="Save As File Name")
' See if the user canceled.
If file_name = False Then Exit Sub
' Save the file with the new name.
If LCase$(Right$(file_name, 4)) <> ".xlsm" Then
file_name = file_name & ".xlsm"
End If
ActiveWorkbook.SaveAs Filename:=file_name, FileFormat:=52
End Sub