Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Array Increment

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,47166
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Array Increment
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Array Increment - 5/17/2007 6:24:19 AM   
  mcds99


Posts: 441
Score: 4
Joined: 2/28/2006
Status: offline
This doesn't make sense (to me) if I us a For/Next to incrememt the the array pointer it works fine.
If I use a For/Next to incrmemet the array pointer and do some work it fails.
I get the error Subscript out of range on...
  SET ObjWbk = objXls.ActiveWorkbook.Worksheets(ObjSht)

Is this a timing thing?


      

_____________________________

Sam

Keep it Simple Make it Fun KiSMiF
 
 
Post #: 1
 
 RE: Array Increment - 5/17/2007 2:06:32 PM   
  dm_4ever


Posts: 2724
Score: 46
Joined: 6/29/2006
From: Orange County, California
Status: offline
What if you moved this line: SET ObjXls = CreateObject("Excel.Application") before your For Each...Next statement?

_____________________________

dm_4ever

My philosophy: K.I.S.S - Keep It Simple Stupid
Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to mcds99)
 
 
Post #: 2
 
 RE: Array Increment - 5/18/2007 5:59:30 AM   
  mcds99


Posts: 441
Score: 4
Joined: 2/28/2006
Status: offline
Same results.
It never gets to the second element in the array...

_____________________________

Sam

Keep it Simple Make it Fun KiSMiF

(in reply to dm_4ever)
 
 
Post #: 3
 
 RE: Array Increment - 5/21/2007 12:49:11 AM   
  ebgreen


Posts: 5250
Score: 31
Joined: 7/12/2005
Status: offline
What if you try to echo the value of TabName(i) just before you try to use it?

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to mcds99)
 
 
Post #: 4
 
 RE: Array Increment - 5/21/2007 9:12:28 AM   
  Skie

 

Posts: 58
Score: 0
Joined: 3/2/2006
Status: offline
One of your tabs is missing or mislabelled.  Are you wanting to open multiple instances of the same file?  If not, you should probably only set the excel object once and only open the file once.


      

(in reply to mcds99)
 
 
Post #: 5
 
 RE: Array Increment - 5/22/2007 5:24:06 AM   
  mcds99


Posts: 441
Score: 4
Joined: 2/28/2006
Status: offline
Very strange...
SET ObjXls = CreateObject("Excel.Application")
ObjXls.Workbooks.open XlsPathI
For i = 0 to Ubound(TabName)
ObjSht = TabName(i)
wscript.echo ObjSht
SET ObjWbk = objXls.ActiveWorkbook.Worksheets(ObjSht)
wscript.echo ObjSht
WScript.Sleep(500)
wscript.echo ObjSht
                                    It increments ObjSht to the next IP but never Gets to the Do While??? I'm going to Put the Do While in a function and see...
Do while ObjWbk.Cells(iRow, 1).Value <> ""
    ClmA = Trim(ObjWbk.Cells(iRow, 1).Value)
    ClmB = Trim(ObjWbk.Cells(iRow, 2).Value)
    ClmC = Trim(ObjWbk.Cells(iRow, 3).Value)
Loop
Next

_____________________________

Sam

Keep it Simple Make it Fun KiSMiF

(in reply to Skie)
 
 
Post #: 6
 
 RE: Array Increment - 5/22/2007 5:59:20 AM   
  mcds99


Posts: 441
Score: 4
Joined: 2/28/2006
Status: offline
OMG!

iRow value...

IP V4 networks are 256 - 2 addresses long 254, after the first workbook iRow was set to 255 so the pointer was at the end of the next work sheet.


DOE!

_____________________________

Sam

Keep it Simple Make it Fun KiSMiF

(in reply to mcds99)
 
 
Post #: 7
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Array Increment Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts