Save a workbook from vb6 environment

Posted on 2004-11-27
Medium Priority
Last Modified: 2012-05-05
C:\MyFile.xls has been modified and I need line(s) of code to save it from a vb6 form.

Question by:Mike Eghtebas
1 Comment
LVL 32

Accepted Solution

Erick37 earned 1200 total points
ID: 12686925
Try this out:

Dim xlWorkbook As Object ' Workbook

On Error Resume Next

Set xlWorkbook = GetObject("C:\MyFile.xls")

If Err.Number = 0 Then
    xlWorkbook.SaveAs "C:\MyFile.xls"
    Set xlWorkbook = Nothing
    Debug.Print "File saved"
End If

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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
Course of the Month16 days, 4 hours left to enroll

850 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