I am running Excel 2010. I have written a macro to save the excel file as a file name which is unique on every save by users. Cell B5 is the current date (28-Aug-14), cell R5 is the machine name and cell D5 is a person's name. Cells R5 and D5 pick from a list from data validation. Using a one press command button, I would like the file to save to two different places (hard drive and server) and then print the worksheet on the default printer. I wrote the following macro for the command button:
Private Sub CommandButton1_Click()
Dim Path As String
Dim FileName1 As String
Dim FileName2 As String
Dim FileName3 As String
Path = "C:\CG-1 Log Sheets\2014\"
FileName1 = Range("B5")
FileName2 = Range("R5")
FileName3 = Range("D5")
ThisWorkbook.SaveAs Filename:=Path & FileName1 & "." & FileName2 & "." & FileName3 & ".xlsm", FileFormat:=xlNormal
Path = "V:\h09sv-alb1\albion\CG-1\CG-1 Log Sheets\2014\"
ThisWorkbook.SaveAs Filename:=Path & FileName1 & "." & FileName2 & "." & FileName3 & ".xlsm", FileFormat:=xlNormal
End Sub
Sub Print_Active_Worksheet()
Application.Dialogs(xlDialogPrint).Show
End Sub
That gives me the following reply:
Run-time error '1004'
And it highlights in yellow the following line in the macro:
ThisWorkbook.SaveAs Filename:=Path & FileName1 & "." & FileName2 & "." & FileName3 & ".xlsm", FileFormat:=xlNormal
It is the first of two lines that are the same in the macro.
I would appreciate if anybody had any suggestions. Thank you for your help. I appreciate it.
Gabe
Bookmarks