Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Attachmate to Excel, SaveAs the open Workbook

Status
Not open for further replies.

tps14334

Technical User
Dec 8, 2008
21
US
I have done alittle poking around on here and trying different resources that I know of and still end up with a scripting error when trying to save the open workbook.

Here is the code to call the Excel session:
Code:
        Dim xlApp As Object, xlSheet As Object
        Set xlApp = CreateObject("excel.application")
        xlApp.Application.DisplayAlerts = False 'Turn off Warning Messages'
        xlApp.Visible = True
        xlApp.Workbooks.Open FileName:=" file location "
        Set xlSheet = xlApp.activesheet

Here is method one I tried that faild after trying to use information from a post on here:
Code:
        xlApp.displayalterts=false
        xlApp.workbookobject.save

Here is method two I tried that also failed after trying to immitate excel's macro recorder:
Code:
        xlApp.SaveAs Filename:= " file location ", FileFormat:=xlExcel8, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, CreateBackup:=False

Can someone help shed some light on this?
 
Hi,

I think the problem is that you haven't declared the workbook itself as an object.

Try this:

In your declarations:

Code:
dim xlWorkbook as object

Then to open and save the workbook:

Code:
Set xlWorkbook = xlApp.Workbooks.Open("Test.xls")
xlWorkbook.SaveAs("TestSave.xls")

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top