Run-time error 1004. Application-defined or object-defined error

  • Thread starter Thread starter Martin Brennan
  • Start date Start date
M

Martin Brennan

The code for this procedure was originally written in Excel 2000 on a
machine using Windows 2000, I am in the process of moving this and others to
a machine using Windows XP Home and Excel 2000.

I get the above error with the third line of the following code. This has
previously run successfully.

MarketWatchRng.Offset(0, 3).Value = MarketWatchPos2Str

MarketWatchRng.Offset(0, 4).Value = MarketWatchPos4Str

MarketWatchRng.Offset(0, 5).Value = MarketWatchPos5Str
'*** Error occurs at this line***


Debug.Print MarketWatchRng.Offset(0, 3).Address
Debug.Print MarketWatchPos2Str
Debug.Print MarketWatchRng.Offset(0, 4).Address
Debug.Print MarketWatchPos4Str
Debug.Print MarketWatchRng.Offset(0, 5).Address
Debug.Print MarketWatchPos5Str

produces the following in the Immediate window.

$D$7055
$E$7055
at=",2" mwfield="Price">6,550.20</SPAN></SPAN><IMG
$F$7055
="UK:1805550" mwformat=",2" mwfield="Price">6,550.20</S

I don't know where to start to look to eliminate the error. Any suggestions
greatly appreciated.

Thanks
Martin
 
Looks like you have mis-matched quotes. What code populates
MarketWatchPos5Str ?

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)
 
Bob,
Thanks for the swift reply, I've posted the code below and marked the
relevant lines with asterisks. Any help is appreciated.
Martin

Set MarketWatchRng = AIE1_01.Range("a65536").End(xlUp).Offset(1, 0)

MarketWatchUrlStr =
"http://www.marketwatch.com/quotes/uk/ftse100?sid=123797"

MarketWatchSrcStr = "MarketWatch"

MarketWatchString1 = "QuoteTime1"

MarketWatchString2 = "BigPriceClass"

MarketWatchTimeout = Now
IE_1.Navigate MarketWatchUrlStr

Do Until Not IE_1.busy Or ( _
Now - MarketWatchTimeout) > TimeValue("00:00:10"): DoEvents: Loop

Do Until IE_1.readystate = 4 Or ( _
Now - MarketWatchTimeout) > TimeValue("00:00:15"): DoEvents:
Loop

If IE_1.readystate = 4 Then
If InStr(IE_1.document.body.innerhtml, _
MarketWatchString1) <> 0 Then


MarketWatchPos1Lng = InStr(IE_1.document.body.innerhtml,
_
MarketWatchString1)

MarketWatchPos2Str = Mid(IE_1.document.body.innerhtml, _
MarketWatchPos1Lng + 108, 8)
'*** Get MarketWatchPos3Lng ***

MarketWatchPos3Lng = InStr(IE_1.document.body.innerhtml,
_
MarketWatchString2)

MarketWatchPos4Str = Mid(IE_1.document.body.innerhtml, _
MarketWatchPos3Lng + 120,
50)

'*** Use MarketWatchPos3Lng to get MarketWatchPos5Str ***

MarketWatchPos5Str = Mid(IE_1.document.body.innerhtml, _
MarketWatchPos3Lng + 100,
55)


MarketWatchRng.Offset(0, 3).Value = MarketWatchPos2Str

MarketWatchRng.Offset(0, 4).Value = MarketWatchPos4Str

MarketWatchRng.Offset(0, 5).Value = MarketWatchPos5Str

Debug.Print MarketWatchRng.Offset(0, 3).Address
Debug.Print MarketWatchPos2Str
Debug.Print MarketWatchRng.Offset(0, 4).Address
Debug.Print MarketWatchPos4Str
Debug.Print MarketWatchRng.Offset(0, 5).Address
Debug.Print MarketWatchPos5Str
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top