Re: Fails then continues without error
- From: Joel <Joel@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Sun, 21 Sep 2008 13:40:01 -0700
I thought I tried a Do Events. thanks for the help. I just got a different
solution working. I think the problem has to do with WORD reading the HTML
file. When I use Window Explorer to look at the HTML file it has a word
ICON. I believe the Get OBJECT is reading the file into word.
My solution was to open an Internet Explorer application a put the filename
as the URL. I din't get any errors.
Sub test()
TempPath = Environ("Temp")
FName = TempPath & "\OutlookTMP.HTML"
Set IE = CreateObject("InternetExplorer.Application")
IE.Application.Visible = True
URL = FName
IE.Navigate2 URL
Do While IE.readyState <> 4
DoEvents
Loop
Set TBL = IE.document.getelementsbytagname("Table")
'find Net and Gross
'For Each itm In TBL
' Set TBLRows = itm.Rows
' Exit For
'Next itm
Set TBLRows = TBL.Item(0).Rows
End Sub
"keiji kounoike" wrote:
I could duplicate your problem. it seems very strange to me it gives.
error, though it runs without problem in debug mode. by trial and error,
i found it runs without problem if i give excel a wait. for example,
do loop, wait, msgbox etc will do in my case. among them, below is the
most simple one in my enviroment. but i don't know why it works.
Sub test()
TempPath = Environ("Temp")
FName = TempPath & "\OutlookTMP.HTML"
Set IEObj = GetObject(FName)
DoEvents '<== add
Set TBL = IEObj.getelementsbytagname("Table")
'find Net and Gross
Set TBLRows = TBL.Item(0).Rows '<= Error occurs here
MsgBox TBLRows.Item(0).Cells.Item(1).Children.Item(0).innertext
End Sub
keiji
Joel wrote:
I trying to solve another posting. Can't get paste this error. Last line of
macro is giving Run Time Error 91 , Object Variable or With Block Variable
not set. I'm using excel 2003.
After the error, I can continue without any error. Itried to put On Error
Resume Next and the error still occurs.
I have created a 2 x 4 table in Outlook and saved the data to an HTML file.
I included the HTML text file. To duplicate the problem simply take the HTML
file below an copy to a notepad application and save the file as
OutlookTMP.HTML. You can double click on the file and an Internet explorer
will come up with the table.
Next run the code below changing the folder to match the directory where the
HTML file is located. I used the envirnomental path variable TEMP.
Sub test()
TempPath = Environ("Temp")
FName = TempPath & "\OutlookTMP.HTML"
Set IEObj = GetObject(FName)
Set TBL = IEObj.getelementsbytagname("Table")
'find Net and Gross
Set TBLRows = TBL.Item(0).Rows '<= Error occurs here
End Sub
Put text below in file called OutlookTMP.HTML
--------------------------------------------------------------------------------
<html>
<head>
snipped
- Follow-Ups:
- Re: Fails then continues without error
- From: keiji kounoike
- Re: Fails then continues without error
- References:
- Fails then continues without error
- From: Joel
- Re: Fails then continues without error
- From: keiji kounoike
- Fails then continues without error
- Prev by Date: Re: Merge Worksheets w/Comments & Hyperlinks
- Next by Date: Re Excel 2007 Trend Equations
- Previous by thread: Re: Fails then continues without error
- Next by thread: Re: Fails then continues without error
- Index(es):
Relevant Pages
|