Hi All,
I have this code from another project that I am trying to adapt for another, but for some reason it wont work. The original was written in Excel 2003, I am now using 2007.
=====
It seems to be hanging on
But I cant seem to see why, any ideas?
Also, how do I stop Excel from throwing up privacy errors because I am using macros every time I save?
Thanks!
I have this code from another project that I am trying to adapt for another, but for some reason it wont work. The original was written in Excel 2003, I am now using 2007.
=====
PHP:
Sub Generate_Office_Copy()
' On Error GoTo oops:
Dim Response As VbMsgBoxResult
Response = MsgBox("All entered information will now be saved as a New File." & vbCrLf & _
"Are you sure you want to continue?", vbQuestion + vbYesNo, "KHS Service Sheet Office Copy Generation")
If Response = vbNo Then Exit Sub
ActiveWorkbook.save
Dim newfile As String, ssno As String, eng As String, cust As String, loc As String
ssno = Range("Y2").Value
eng = Range("F19").Value
cust = Range("G44").Value
'loc = Range("j4").Value
newfile = ssno & ", " & eng & ", " & cust & "_" & " Service Report.xlsm"
ChDir ActiveWorkbook.Path
' "C:\Documents and Settings\KHS\Desktop\Drafts"
ActiveWorkbook.SaveAs Filename:=newfile
' If Filename.newfile Then GoTo oops
MsgBox "Service Report Saved in the directory;" & vbCrLf & _
vbCrLf & _
ActiveWorkbook.Path & "\" & newfile & vbCrLf & _
vbCrLf & _
"PLEASE MAKE A NOTE OF THIS LOCATION FOR WHEN FOR FUTURE EDITING / MAILING!" & vbCrLf & _
vbCrLf & "If you need to make further changes to this sheet then do so in the normal way (i.e file - save etc)" & _
vbCrLf & _
vbCrLf & _
"=================[ NB: This is the OFFICCE COPY! ]================" & vbCrLf & _
"If you need to make another Service Sheet please Re-open the MASTER DOCUMENT" _
, vbQuestion + vbOKOnly, "Office Copy Created"
' ActiveWorkbook.Close
GoTo finished:
oops:
MsgBox ("The service sheet: " & newfile & " already exists" & vbCrLf & _
vbCrLf & _
"Please change the service sheet number and try again")
finished:
End Sub
It seems to be hanging on
PHP:
ActiveWorkbook.SaveAs Filename:=newfile
But I cant seem to see why, any ideas?
Also, how do I stop Excel from throwing up privacy errors because I am using macros every time I save?
Thanks!