He4Giv
asked on
Write Code to save an Excel File
How do I write code at the end of my macro that will automatically save a file after the macro does its task? This file will be located on each persons desktop for easy access.
After the macro assigns a PO number I want the file saved automatically (written in the code) and after each user fill out their order form it will be up to them to do a manual "Save As" to their proper folder.
here is my macro for further reference.....
Public Sub GetNewJobNumber()
Dim strJob As String
strJob = InputBox("Enter job number")
Worksheets("Access & Couplers").Range("I9") = strJob & "-" _ & Worksheets("PONumber").Ran ge("A1")
Worksheets("PoNumber").Ran ge("A1:A1" ).Delete
End Sub
After the macro assigns a PO number I want the file saved automatically (written in the code) and after each user fill out their order form it will be up to them to do a manual "Save As" to their proper folder.
here is my macro for further reference.....
Public Sub GetNewJobNumber()
Dim strJob As String
strJob = InputBox("Enter job number")
Worksheets("Access & Couplers").Range("I9") = strJob & "-" _ & Worksheets("PONumber").Ran
Worksheets("PoNumber").Ran
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Yours didnt work but was close so I checked VB help and found the syntax to be....
ActiveWorkbook.Save
This saved the file for me
Thanks
ActiveWorkbook.Save
This saved the file for me
Thanks
Public Sub GetNewJobNumber()
Dim strJob As String
strJob = InputBox("Enter job number")
Worksheets("Access & Couplers").Range("I9") = strJob & "-" _ & Worksheets("PONumber").Ran
Worksheets("PoNumber").Ran
ChDir "C:\WINDOWS\Desktop"
ActiveWorkbook.SaveAs Filename:="temp.xls", FileFormat:= _
xlNormal, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False
, CreateBackup:=False
End Sub
Cheers...
Ber...