Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBA macro in WORD 1

Status
Not open for further replies.

FractalWalk

Technical User
Nov 18, 2002
141
US
I'm using a macro in Word 2002 that pulls data off the web. Ideally, the code will loop 100,000 times (to pull 100,000 pages). However, at seemingly random times, the target page can't be opened and I get an error message that states the file name or path is invalid. This error doesn't just interrupt the code, it completely stops the macro. This occurs in both Wondows 2000 and Windows 98.

I have placed Application.DisplayAlerts=False into the code and an Error Handler to continue looping when an error occurs, but that doesn't help this particular error. The message still pops up and kills the code.

The error itself is a bit of a mystery to me as the target address exists and when I manually access it, it loads just fine. In other words both the file name and path are valid. A search on the web for this error found some info about disabling Smart tags but that didn't help either. Perhaps it is a connectivity issue.

Assuming that the error itself can't be avoided, I need a fix to prevent the error from stopping the code.
 
You can use the On Error Statement to deal with errors. Also, if you provided more information such as the line of code that's erroring out, maybe we could be of more help to you.

Example of On Error

On Error Resume Next
'This turns off the error code handling, but you could get some unexpected results, so you should use this with care.

Ronald R. Dodge, Jr.
Production Statistician
Master MOUS 2000
 
I changed the On Error code to

On Error Resume Next

and it seemed to stop the pop-up box from occuring, although I'm not sure why. I added some code into the macro to help prevent unwanted results from this and it seems to be working so far. Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top