Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - Anyway to add worksheets on loop

Reply
 
Old 10-14-2008   #1 (permalink)
RICK


 
 

Anyway to add worksheets on loop

Set rsTemp = server.createobject("adodb.recordset")
conn.Webqry_SelectList rsTemp
do while not rstemp.eof

Add worksheet here

loop

My System SpecsSystem Spec
Old 10-14-2008   #2 (permalink)
Jennifer


 
 

Re: Anyway to add worksheets on loop

On Oct 14, 11:33*am, RICK <R...@xxxxxx> wrote:
Quote:

> Set rsTemp = server.createobject("adodb.recordset")
> conn.Webqry_SelectList rsTemp
> do while not rstemp.eof
>
> Add worksheet here
>
> loop
Hope this helps! - Jennifer

' Watch for word wrap!
Dim XL
Dim WB

' First create the Excel workbook
Set XL = GetObject(, "Excel.Application")
If Err.Number <> 0 Then
Set XL = CreateObject("Excel.Application")
End If

Set WB = XL.Workbooks.Add Set XL = GetObject(, "Excel.Application")
If Err.Number <> 0 Then
Set XL = CreateObject("Excel.Application")
End If
' Add a workbook to the Excel File
Set WB = XL.Workbooks.Add

'Do your stuff to create your connection and recordsets

Set rsTemp = server.createobject("adodb.recordset")
conn.Webqry_SelectList rsTemp
do while not rstemp.eof
'Add the worksheet to the workbook
WB.Worksheets.Add.Move after:=WB.Worksheets(WB.Worksheets.Count)
loop
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
RE: How to do something in an VBS script for all worksheets of an Exce VB Script
Re: How to do something in an VBS script for all worksheets of an Excel file? VB Script
RE: How to do something in an VBS script for all worksheets of an Exce VB Script
Excel 2007/ Vista- Problem Duplicating Worksheets Within Same Work Vista General
Accept terms & conditions message for Excel worksheets Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46