Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Error Continue in Excel VBA

Posted on 2007-11-20
2
Medium Priority
?
976 Views
Last Modified: 2008-02-01
This is Excel 2003.
I have this “File” that I have linked to and I need to save every 13 seconds to keep it live.  

But sometimes the original file is saving and my procedure errors out.   How do you tell it to   “ If  error then continue” without popping up the error, so I don’t have to manually do it.

Any help would greatly be appreciated.
'//////////////////////////////////////////////////////////
Sub UpdateLinks()'

    ActiveWorkbook.UpdateLink Name:= _
        "\\DTCNAS-ILSP002\Test.xls" _
        , Type:=xlExcelLinks
    Range("A1").Select
   
    Call UpdateTime
End Sub


Sub UpdateTime()

Application.OnTime Now + TimeValue("00:00:13"), "UpdateLinks"

End Sub
0
Comment
Question by:ca1358
2 Comments
 
LVL 13

Expert Comment

by:Michael_D
ID: 20322464
Try this


Sub UpdateLinks()'
 
On Error GoTo ErrorHandler
 
    ActiveWorkbook.UpdateLink Name:= _
        "\\DTCNAS-ILSP002\Test.xls" _
        , Type:=xlExcelLinks
    Range("A1").Select
   
    Call UpdateTime
ErrorHandler:
    ' Do whatever want to do if error occures
End Sub

Open in new window

0
 
LVL 17

Accepted Solution

by:
Shanmuga Sundaram earned 2000 total points
ID: 20402000
Though using "On Error Resume Next" is not advicable during in need we can use them.

Sub UpdateLinks()'
On Error Resume Next
    ActiveWorkbook.UpdateLink Name:= _
        "\\DTCNAS-ILSP002\Test.xls" _
        , Type:=xlExcelLinks
    Range("A1").Select
   
    Call UpdateTime
End Sub


Sub UpdateTime()
On Error Resume Next
Application.OnTime Now + TimeValue("00:00:13"), "UpdateLinks"
End Sub
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

927 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question