Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Afternoon,
I am trying to get used to creating macros in VBS in QV and I can't seem to figure out why the following is happening. I'm used to working with VBA but can't spot the issue here.
When I click the button to run the macro everything works fine up to the point of the loop. The loop initially works perfectly but then exits the sub, it never reaches the last message box for some reason.
Am I using the For ...next correctly?
Thanks in advance
Chris
Sub Test()
dim chart,ColumnCount,b,found
set chart = ActiveDocument.GetSheetObject("CH212")
found = false
ColumnCount = chart.getcolumncount
if ColumnCount = 1 then
msgbox "Count is Null"
exit sub
end if
msgbox ColumnCount
for b = 0 to ColumnCount
if chart.getfield(b).name = "entity" then
msgbox "Entity Already exists and is in position: " & b
found = true
else
msgbox "Skipped: Column" & b <------ I see this
end if
msgbox "Still going" <------ I also see this
next
msgbox "Finished Loop and Found flag = " & found <------ I never see this
end sub
Perhaps ColumnCount is 0 or undefined.
Try it with:
...
for b = 0 to ColumnCount - 1
...
- Marcus