PDA

View Full Version : Catching an error?



te4t0n
12-03-2007, 03:47 PM
Hello, i have this code:

Dim i As Integer
For i = 1 To 800
Selection.PasteAndFormat (wdPasteDefault)
Selection.MoveLeft Unit:=wdCharacter, Count:=5
Selection.TypeBackspace
Selection.TypeBackspace
Selection.TypeText Text:=i
Selection.EndKey Unit:=wdLine
Selection.TypeParagraph
Next i


Which when i have a link copied, will paste it below, delete the last two digits and then add a number on the end. Works great, But!

What i need now is to try and open a hyperlink and catch an error. you cannot use macros to record the clicking of a hyperlink so i don't knwo the code for it and how would i catch this error ("Unable to open http ... .com" Cannot locate the internet server or Proxy server) thks.

TonyJollans
12-04-2007, 09:39 AM
Even if you could trap the hyperlinking event it probably wouldn't help you - a 404 error page is still a successful hyperlink - just not to where you wanted to go. Word doesn't query browser redirections.

I don't know how to do this but you will need to instantiate a browser object and somehow work with that. I'm sure there are people here who do know how to do it.

te4t0n
12-04-2007, 12:03 PM
when i open a 404 error page in word, i mean when i open a webistie that majkes the browser show a 404 page, word 2007 knows this a displayed an error in word and doesn't open the website.. i hope someone reads this and helps me.

TonyJollans
12-04-2007, 01:13 PM
I'm intrigued. What error and how is it presented? I just get an IE7 page saying it can't be displayed.

te4t0n
12-04-2007, 01:37 PM
Well take alook here and you can see:

i cannot show a url, not enough posts yet. i attached it as an image hope this work... :)

i'm using office 2007 and firefox 2 (uptodate) as my default browser.

TonyJollans
12-04-2007, 01:55 PM
That message implies it has failed to find the internet, not failed to find the page. Your browser hasn't been started; the page hasn't been looked for in the big wide world because, for whatever reason, Word can't get through the gateway into it ---- I THINK!!!!

I must say I'm way out of my depth here - but interested :)

te4t0n
12-04-2007, 02:00 PM
i just think they have been lazy and it shows that message for several conditions, one been when a page shows 404 error, becuase if i put it in firefox u get a 404 error and if i open a known working link in word after or before the broken link the error message apperas only for the broke link and the working ones open as expected. anyway i'll just do it all by hand it will be quicker in the end, but i would love to know how to do it in programming.

TonyJollans
12-04-2007, 02:30 PM
See http://support.microsoft.com/kb/218153