Link to home
Start Free TrialLog in
Avatar of He4Giv
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").Range("A1")
 Worksheets("PoNumber").Range("A1:A1").Delete
 End Sub
Avatar of Ber
Ber

I think something like this should work

Public Sub GetNewJobNumber()

Dim strJob As String

strJob = InputBox("Enter job number")
Worksheets("Access & Couplers").Range("I9") = strJob & "-" _ & Worksheets("PONumber").Range("A1")
Worksheets("PoNumber").Range("A1:A1").Delete

ChDir "C:\WINDOWS\Desktop"
    ActiveWorkbook.SaveAs Filename:="temp.xls", FileFormat:= _
        xlNormal, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False _
        , CreateBackup:=False
End Sub

Cheers...
Ber...
ASKER CERTIFIED SOLUTION
Avatar of Chandramouli k
Chandramouli k
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of He4Giv

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