Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   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: 26
Default How to do something in an VBS script for all worksheets of an Excel file?

I would like to do something in a *.vbs script and all the operations should be applied
on each worksheet within an Excel file.

How do I do this?

It must be something like:

for i in (1 .. lastworksheetnumber) do
...operations
end


Claudia

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,420
Default How to do something in an VBS script for all worksheets of an Excel file?

For i = 1 To Activeworkbook.Worksheets.Count

... operations on Activeworkbook.Worksheets(i)

Next i

--
__________________________________
HTH

Bob

"Claudia d'Amato" wrote in message
...
I would like to do something in a *.vbs script and all the operations
should be applied
on each worksheet within an Excel file.

How do I do this?

It must be something like:

for i in (1 .. lastworksheetnumber) do
...operations
end


Claudia



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default How to do something in an VBS script for all worksheets of anExcel file?

Claudia d'Amato schrieb:
I would like to do something in a *.vbs script and all the operations should be applied
on each worksheet within an Excel file.

How do I do this?

It must be something like:

for i in (1 .. lastworksheetnumber) do
...operations
end


Claudia

Dim oFS : Set oFS = CreateObject( "Scripting.FileSystemObject" )
Dim oExcel : Set oExcel = CreateObject( "Excel.Application" )
Dim sFSpec : sFSpec = oFS.GetAbsolutePathName( "<yourxlsfile" )
Dim oWBook : Set oWBook = oExcel.Workbooks.Open( sFSpec )
Dim oSheet
For Each oSheet In oWBook.WorkSheets
WScript.Echo oSheet.Name
...
Next
oWBook.Close True ' Save SaveAs ...
oExcel.Quit
  #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: 3,942
Default How to do something in an VBS script for all worksheets of an Exce

hi
something like this might work...
Sub claudia()
For i = 1 To Worksheets.Count
Worksheets(i).Range("A1").Interior.ColorIndex = 6
'above is for test only
Next i
End Sub

regards
FSt1


"Claudia d'Amato" wrote:

I would like to do something in a *.vbs script and all the operations should be applied
on each worksheet within an Excel file.

How do I do this?

It must be something like:

for i in (1 .. lastworksheetnumber) do
...operations
end


Claudia


  #5   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: 11,501
Default How to do something in an VBS script for all worksheets of an Exce

Hi

Sub sonic()

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

end sub


depemding on what you are doing you may not (probably won't) need to select

Mike

"Claudia d'Amato" wrote:

I would like to do something in a *.vbs script and all the operations should be applied
on each worksheet within an Excel file.

How do I do this?

It must be something like:

for i in (1 .. lastworksheetnumber) do
...operations
end


Claudia




  #6   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: 586
Default How to do something in an VBS script for all worksheets of an Exce

This should be nice and easy for you.

Dim sh As Worksheet

For Each sh In Worksheets
'your code here
Next sh

Hope this helps!
--
Cheers,
Ryan


"Claudia d'Amato" wrote:

I would like to do something in a *.vbs script and all the operations should be applied
on each worksheet within an Excel file.

How do I do this?

It must be something like:

for i in (1 .. lastworksheetnumber) do
...operations
end


Claudia


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default How to do something in an VBS script for all worksheets of an Excelfile?

Do you really mean .VBS?

If yes:

=================

Dim xlApp
Dim xlWkbk
Dim xlWks

Set xlApp = CreateObject("Excel.application")
'xlApp.Visible = True
Set xlWkbk = xlApp.Workbooks.Open("C:\book1.xls")

For Each xlWks In xlWkbk.worksheets
xlWks.Columns.AutoFit
Next xlWks

xlWkbk.Close True

xlApp.Quit

Set xlWks = Nothing
Set xlWkbk = Nothing
Set xlApp = Nothing

=================
It's nice to see what's happening when you're debugging. That's why I kept the
..visible line in the pasted code.

Claudia d'Amato wrote:

I would like to do something in a *.vbs script and all the operations should be applied
on each worksheet within an Excel file.

How do I do this?

It must be something like:

for i in (1 .. lastworksheetnumber) do
...operations
end

Claudia


--

Dave Peterson
  #8   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 Excel file?

Hi guy/girls

It seems that there is somebody active in the newsgroups who is trying to
disturp a lot, by creating a special kind of follow up.

Will you be so kind to stop replying to this person, speaking here from the
dotnet language newsgroup.

We are very interested in scripting, excel or whatever.

But when we want that information we visit those news groups.

Thanks in advance

Cor

  #9   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,420
Default How to do something in an VBS script for all worksheets of an Excel file?

This seems a tad OTT. What is wrong with this question?

--
__________________________________
HTH

Bob

"Cor Ligthert[MVP]" wrote in message
...
Hi guy/girls

It seems that there is somebody active in the newsgroups who is trying to
disturp a lot, by creating a special kind of follow up.

Will you be so kind to stop replying to this person, speaking here from
the dotnet language newsgroup.

We are very interested in scripting, excel or whatever.

But when we want that information we visit those news groups.

Thanks in advance

Cor



  #10   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 Excel file?

I would like to do something in a *.vbs script and all the operations should
be applied
on each worksheet within an Excel file.

As you can tell me what this has to do with VB for Net, then I agree with
you.

Cor




  #11   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,420
Default How to do something in an VBS script for all worksheets of an Excel file?

Well seeing as I am answering it in an Excel group, it seems totally
relevant.

--
__________________________________
HTH

Bob

"Cor Ligthert [MVP]" wrote in message
...
I would like to do something in a *.vbs script and all the operations
should be applied
on each worksheet within an Excel file.

As you can tell me what this has to do with VB for Net, then I agree with
you.

Cor



  #12   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: 3
Default How to do something in an VBS script for all worksheets of anExcel file?

On Jun 25, 7:09 am, "Bob Phillips" wrote:
Well seeing as I am answering it in an Excel group, it seems totally
relevant.


Yes, but the person who posted the question, cross posted it to
the .Net group where it is off topic. I think Cor was requesting that
you remove the .Net group from the follow up.

Cheers,

Chris
Reply
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 do something in an VBS script for all worksheets of an Excel file? Claudia d'Amato Excel Discussion (Misc queries) 9 June 26th 08 10:53 PM
Save Excel File every wednesday VB Script Help sam76210 Excel Programming 2 March 8th 06 08:12 PM
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
An Excel environment started from a VB script .vbs file. Jerry[_11_] Excel Programming 0 July 15th 03 08:21 PM


All times are GMT +1. The time now is 10:17 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"