SoftTree Technologies SoftTree Technologies
Technical Support Forums
RegisterSearchFAQMemberlistUsergroupsLog in
Excel Automation - Calling 'SaveAS'

 
Reply to topic    SoftTree Technologies Forum Index » 24x7 Scheduler, Event Server, Automation Suite View previous topic
View next topic
Excel Automation - Calling 'SaveAS'
Author Message
rezakhan



Joined: 06 Sep 2007
Posts: 9

Post Excel Automation - Calling 'SaveAS' Reply with quote
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 View user's profile Send private message Send e-mail
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7955

Post Reply with quote
something like this should work
xlsObj.SaveAs ( "file name here", -4143 , , , , , True )

for more details please see

http://msdn2.microsoft.com/en-us/library/microsoft.office.tools.excel.workbook.saveas(VS.80).aspx
Thu Sep 06, 2007 10:20 am View user's profile Send private message
rezakhan



Joined: 06 Sep 2007
Posts: 9

Post Excel Automation - Calling 'SaveAS' Reply with quote
Thanks Sysop , will try.
Reza[/quote]
Thu Sep 06, 2007 10:29 am View user's profile Send private message Send e-mail
rezakhan



Joined: 06 Sep 2007
Posts: 9

Post Exel Automation Reply with quote
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 View user's profile Send private message Send e-mail
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7955

Post Reply with quote
Hi,

Please try it without parentesis

Code:
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 View user's profile Send private message
rezakhan



Joined: 06 Sep 2007
Posts: 9

Post Excel Automation - Calling 'SaveAS' Reply with quote
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 View user's profile Send private message Send e-mail
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7955

Post Reply with quote
Code:
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 View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7955

Post Reply with quote
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 View user's profile Send private message
rezakhan



Joined: 06 Sep 2007
Posts: 9

Post Excel Automation Reply with quote
Hi SysOp , many thanks and have a good day.

Reza
Thu Sep 06, 2007 12:18 pm View user's profile Send private message Send e-mail
Display posts from previous:    
Reply to topic    SoftTree Technologies Forum Index » 24x7 Scheduler, Event Server, Automation Suite All times are GMT - 4 Hours
Page 1 of 1

 
Jump to: 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


 

 

Powered by phpBB © 2001, 2005 phpBB Group
Design by Freestyle XL / Flowers Online.