Solved

Write Code to save an Excel File

Posted on 2002-04-10
3
130 Views
Last Modified: 2010-05-02
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
0
Comment
Question by:He4Giv
3 Comments
 
LVL 2

Expert Comment

by:Ber
ID: 6932568
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...
0
 
LVL 5

Accepted Solution

by:
kcm76 earned 50 total points
ID: 6932586
How about just **Worsheets(X).save**

kcm
0
 

Author Comment

by:He4Giv
ID: 6932764
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
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now