[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now


Write Code to save an Excel File

Posted on 2002-04-10
Medium Priority
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")
 End Sub
Question by:He4Giv
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Expert Comment

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")

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


Accepted Solution

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


Author Comment

ID: 6932764
Yours didnt work but was close so I checked VB help and found the syntax to be....


This saved the file for me


Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

649 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