#1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 131
Default On error

Hi, I have code as below which will update links..

On error sheet will be unlocked.. how to lock the sheet again and exit sub?

Sub ref()

ActiveSheet.Unprotect Password:="abc"

ActiveWorkbook.UpdateLink Name:= _
"asdasd", _
Type:=xlExcelLinks

ActiveSheet.Protect Password:="abc"

End Sub

  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 8,520
Default On error

Try using the On Error statement.. Refer the below link

Sub ref()

On Error GoTo Handler

ActiveSheet.Unprotect Password:="abc"
ActiveWorkbook.UpdateLink Name:= _
"asdasd", Type:=xlExcelLinks
ActiveSheet.Protect Password:="abc"

Handler:
ActiveSheet.Protect Password:="abc"

End Sub


If this post helps click Yes
---------------
Jacob Skaria


"Kashyap" wrote:

Hi, I have code as below which will update links..

On error sheet will be unlocked.. how to lock the sheet again and exit sub?

Sub ref()

ActiveSheet.Unprotect Password:="abc"

ActiveWorkbook.UpdateLink Name:= _
"asdasd", _
Type:=xlExcelLinks

ActiveSheet.Protect Password:="abc"

End Sub

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 8,520
Default On error

Kashya, this time with the link.

http://www.excel-vba.com/vba-code-2-2-error.htm

If this post helps click Yes
---------------
Jacob Skaria


"Kashyap" wrote:

Hi, I have code as below which will update links..

On error sheet will be unlocked.. how to lock the sheet again and exit sub?

Sub ref()

ActiveSheet.Unprotect Password:="abc"

ActiveWorkbook.UpdateLink Name:= _
"asdasd", _
Type:=xlExcelLinks

ActiveSheet.Protect Password:="abc"

End Sub

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 131
Default On error

Thanks Jacob..

"Jacob Skaria" wrote:

Try using the On Error statement.. Refer the below link

Sub ref()

On Error GoTo Handler

ActiveSheet.Unprotect Password:="abc"
ActiveWorkbook.UpdateLink Name:= _
"asdasd", Type:=xlExcelLinks
ActiveSheet.Protect Password:="abc"

Handler:
ActiveSheet.Protect Password:="abc"

End Sub


If this post helps click Yes
---------------
Jacob Skaria


"Kashyap" wrote:

Hi, I have code as below which will update links..

On error sheet will be unlocked.. how to lock the sheet again and exit sub?

Sub ref()

ActiveSheet.Unprotect Password:="abc"

ActiveWorkbook.UpdateLink Name:= _
"asdasd", _
Type:=xlExcelLinks

ActiveSheet.Protect Password:="abc"

End Sub

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Visual Basic Error Run Time Error, Type Mismatch Meg Partridge Excel Discussion (Misc queries) 12 September 10th 08 06:10 PM
Counting instances of found text (Excel error? Or user error?) S Davis Excel Worksheet Functions 5 September 12th 06 04:52 PM
I have Error 1919 Error Configuring ODBC dataSource Database Texanna1 Excel Discussion (Misc queries) 1 September 12th 06 06:35 AM
Excel 2003 Macro Error - Runtime error 1004 Cow Excel Discussion (Misc queries) 2 June 7th 05 01:40 PM


All times are GMT +1. The time now is 11:23 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"