LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.scripting.vbscript,microsoft.public.dotnet.languages.vb,microsoft.public.excel.misc,microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default How to do something in an VBS script for all worksheets of an Exce

Il giorno Tue, 24 Jun 2008 14:15:04 -0700, ?B?TWlrZSBI?=
ha scritto:
Sub sonic()
for x=1 to worksheets.count
worksheets(x).select
'do your stuff
next
end sub


I'm not sure if this works with already opened worksheets. If it's not, you have to open
every single xls before working on it.

Set xl=CreateObject("excel.application")
xl.Visible=True

'xl.Workbooks.Open Filename

for x=1 to xl.worksheets.count
xl.worksheets(x).select
'do your stuff
next


If you want to run an existing xls macro from a vbs:

filePath = "c:\Test.xls"
Set oExcel = CreateObject("Excel.Application")
oExcel.Workbooks.Open(filepath)
oExcel.Run "macro1"
oExcel.ActiveWorkbook.Save
oExcel.ActiveWorkbook.Close
oExcel.Quit
Set oExcel = Nothing



--
Giovanni Cenati (Bergamo, Italy)
Write to "Reventlov" at katamail com
http://digilander.libero.it/Cenati (Esempi e programmi in VbScript)
--
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to generate a text file from Excel using a macro or script? Frank Excel Discussion (Misc queries) 1 January 6th 08 05:11 PM
How to generate a text file from Excel using a macro or script? Frank Excel Discussion (Misc queries) 0 January 6th 08 05:11 PM
can't save VBA script when saving excel file thinktwice Excel Discussion (Misc queries) 5 December 27th 06 07:38 AM
Save Excel File every wednesday VB Script Help !! sam76210 Excel Discussion (Misc queries) 0 March 8th 06 04:05 PM
Script to save Excel file to the server. raj41977 Excel Discussion (Misc queries) 3 December 8th 05 02:48 PM


All times are GMT +1. The time now is 05:51 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"