| || |
Works in Function not in Script (May Have It)
What would cause this to run as a function but not a script? I have ALMOST the same thing that runs as a function and I copied it to a script. The function clicks on a report number and the script clicks on all the report numbers.
It fails with "User - defined type not defined" on GetChildElements in THMLTableX. The same setup works in the function?
<font class="small">Code:</font><hr /><pre>
'Create Date = 12/29/2006 Author = BMD
'Last Modify = 12/29/2006 Author = BMD
'Inputs = NONE
'Outputs = Immediate
'Call Like =
Dim FindReport As Boolean
Dim continue As Boolean
Dim tablex As New THMLTableX
TRows = 0
R = 0
FindReport = False
continue = True
Window("Net ProMerit", tpAttachNoWait).Attach
If HTMLDiv("ID='*jobTree*item_1_cell'", tpAttachNoWait).Exists = False Then
DEF = HTMLDiv("ID='*jobTree*item_0_cell'").CaptureText
If InStr(1, DEF, "Default") <> 0 Then
HTMLDiv("ID='*jobTree*item_0_cell'").Click 5, 5
For R = 1 To 40 And FindReport <> "True"
If HTMLDiv("ID='*jobTree*item_" & (R) & "_cell'").Exists Then
HTMLDiv("ID='*jobTree*item_" & (R) & "_cell'").Click 5, 5
lngRowsT = tablex.Rows
If lngRowsT = 0 Then: continue = False
For TRows = 0 To lngRowsT - 1 Or continue = False 'inner report number loop
cellrpttext = Trim$(tablex.CellText(TRows, 0)) ' TRows was R
If htmlTable("ReportOptionTable").Exists = True Then
Debug.Print "" & (cellrpttext) & " Passed"""
ElseIf htmlTable("ReportOptionTable").Exists = False Then
Debug.Print "" & (cellrpttext) & " FAILED"""
If HTMLAnchor("BackReportLink").Exists And (TRows <= (lngRowsT - 1)) Then
continue = True
Thanks for any pointers.
Take the include out and leave the dim in. It is running and I am testing it now.
Re: Works in Function not in Script (May Have It)
From Tools/References Add Microsoft HTML Object Library, and it should work.