kengooch
Member
- Local time
- Today, 15:51
- Joined
- Feb 29, 2012
- Messages
- 137
I have a spreadsheet that I build a file name from the date and the user and then need to store it to their network folder. I have tried numerous things but can't get Excel to change the current folder prior to executing the xlDialogSaveAs command. Here is where I am... any help would be appreciated.
Thanks in advance for any suggestions or help.
Code:
'Build Staff File Save Name
vTitle = "Accomplishment Tracking"
vDate = Date - Weekday(Date, vbUseSystem) + 2
vDate = Format(Date - Weekday(Date, vbUseSystem) + 2, "yyyymmdd")
vWeek = Application.WorksheetFunction.WeekNum(Date)
vLName = Left(Application.UserName, InStr(Application.UserName, " ") - 2)
vFName = Mid(Application.UserName, InStr(Application.UserName, " ") + 1, 1)
'Set Variables for Filename
vPath = "U:\MS-Tools\Accomplishment Tracking\"
ChDir vPath
vFileName = vDate & "-C Wk" & vWeek & " " & vFName & vLName & " Accomplishments" & ".xlsm"
'Save File
Range("B3").Select
fProcessing.Hide
jAgain:
vChk = MsgBox("Welcome to the " & vTitle & " Workbook." & vbCrLf & vbCrLf & "This workbook provides daily worksheets to help you track your Daily Accomplishments." & vbCrLf + vbCrLf & " T H I S I S T H E M A S T E R F O R M" & vbCrLf & "We need to create a working copy on your computer.", vbOKCancel + vbQuestion + vbApplicationModal, vTitle, 5000, 5000)
If vChk = vbOK Then
GoTo jSave
Else
If vChk = vbCancel Then
MsgBox " ! ! ! ! C A U T I O N ! ! ! !" & vbCrLf + vbCrLf _
& "You are working on the Master Document" & vbCrLf + vbCrLf _
& " any changes you make will affect" & vbCrLf _
& " every one using this document!", vbCritical + vbApplicationModal, "System Master Document Warning"
GoTo jend
End If
End If
jSave:
vUserDomain = Environ("UserDomain")
vCompNm = Environ("ComputerName")
vUsrNm = Environ("UserName")
jRetry:
vAppUsrNm = InputBox("You are logged on as " & vUsrNm & vbCrLf & "Please provide your full name." & vbCrLf + vbCrLf & "Example Format ( Kennedy, John F. )", "Verify Application User Name", Application.UserName)
If vAppUsrNm = "" Then
MsgBox "You did not provide an entry. The Save As process will be canceled" & vbCrLf + vbCrLf & "! ! ! CAUTION: YOU ARE WORKING ON THE MASTER SHEET ! ! !", vbOKOnly + vbCritical + vbApplicationModal, "Save As Process Aborted"
vChk = vChk + 1
GoTo jend
End If
Application.UserName = vAppUsrNm
'Try to save to directory
SetCurrentDirectoryA "U:\MS-Tools\Accomplishment Tracking\"
Application.Dialogs(xlDialogSaveAs).Show vFileName
'The line below works, but the user has no involvement
' ThisWorkbook.SaveAs Filename:=vFileName
End Sub
Thanks in advance for any suggestions or help.