Author |
Message |
rezakhan
Joined: 06 Sep 2007 Posts: 9
|
|
Excel Automation - Calling 'SaveAS' |
|
Hi there , I am a newbie with this software and I think it superb.
My problem is that I would like to open an existing excel spreadsheet and 'SaveAS' to a new excel sheet.
I can open no problem , just can't do the Save AS !
Any ideas on the correct call for 'SaveAs' ?
Best regards
Reza
|
|
Thu Sep 06, 2007 6:38 am |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7955
|
|
|
Thu Sep 06, 2007 10:20 am |
|
 |
rezakhan
Joined: 06 Sep 2007 Posts: 9
|
|
Excel Automation - Calling 'SaveAS' |
|
Thanks Sysop , will try.
Reza[/quote]
|
|
Thu Sep 06, 2007 10:29 am |
|
 |
rezakhan
Joined: 06 Sep 2007 Posts: 9
|
|
Exel Automation |
|
Hi SysOp , tried the code and error says 'Cannot use paranthesis when calling sub'
Set objXL = CreateObject("Excel.Application")
FileName = "C:\\247\test.xls"
'Open template excel workbook
objXL.Workbooks.Open(FileName)
'Shove some data into sheet
set xlSheet = objXL.sheets(1)
'send test data into cells
xlSheet.Cells(1,1) = "Hello world"
'Save spreadsheet
objXL.SaveAs("C:\\247\test1.xls",-4143,,,,,true)
'close and release from memory
objXL.application.Quit
set objXL = nothing
|
|
Thu Sep 06, 2007 10:43 am |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7955
|
|
|
|
Hi,
Please try it without parentesis
 |
 |
objXL.SaveAs "C:\247\test1.xls",-4143,,,,,true |
By the way, in VBScript you don't need to use escape symbols for back-slashes.
.
|
|
Thu Sep 06, 2007 10:53 am |
|
 |
rezakhan
Joined: 06 Sep 2007 Posts: 9
|
|
Excel Automation - Calling 'SaveAS' |
|
Hi SysOp , made the change as you suggested.
The error now says 'Object doesn't support this property OR method' ?
Best regards
Reza
|
|
Thu Sep 06, 2007 11:00 am |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7955
|
|
|
|
 |
 |
Sub Main()
Set objXL = CreateObject("Excel.Application")
FileName = "C:\test.xls"
'Open template excel workbook
objXL.Workbooks.Open(FileName)
'Shove some data into sheet
set xlSheet = objXL.sheets(1)
'send test data into cells
xlSheet.Cells(1,1) = "Hello world"
'Save spreadsheet
objXL.ActiveWorkBook.SaveAs "C:\test1.xls",-4143,,,,,true
'close and release from memory
objXL.application.Quit
set objXL = nothing
End Sub |
|
|
Thu Sep 06, 2007 11:41 am |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7955
|
|
|
|
Please note that in addition to "saveas" change, I also changed file names just because I don't have the referenced subfolder. This change is not required.
|
|
Thu Sep 06, 2007 11:43 am |
|
 |
rezakhan
Joined: 06 Sep 2007 Posts: 9
|
|
Excel Automation |
|
Hi SysOp , many thanks and have a good day.
Reza
|
|
Thu Sep 06, 2007 12:18 pm |
|
 |
|