Problem due to password

  • Thread starter Thread starter FuzzyLogic
  • Start date Start date
F

FuzzyLogic

Can any one guide to solve out a problem.

I am reading a excel workbook from a Visual Basic application.
I have to do work in this workbook.

1. I have to assign ToolTip to the particular cells.

2. I have to insert additional rows/columns.

I have to do this as per the logic in Visual Basic application.
The problem is that if the program gives run time error when the exce
workbook is password protected and neither allow me to assign toolti
nor the insert rows/columns.

I m using the following commands

ActiveWorkSheet.Cells(9, 9).AddComment "Testing ToolTips"

Activework.Range("C9", "C9").EntireColumn.Insert xlShiftToRight


Any help will be appreciated in this regard.


:
 
In xl2000 and earlier you can use the UserInteractiveOnly Property of the
protect method to work with the worksheet without knowing the password.

You can check if the sheet is protected with

Sub Tester5()
If ActiveSheet.ProtectContents _
Or ActiveSheet.ProtectDrawingObjects _
Or ActiveSheet.ProtectScenarios Then
On Error Resume Next
ActiveSheet.Unprotect password:=""
If Err.Number <> 0 Then
Err.Clear
MsgBox "Sheet is password protected"
Activesheet.Protect UserInteractiveOnly:=True
End If
On Error GoTo 0
End If


End Sub

In Excel 2002 and later, you would need to know the password.
 
Whoops, UserInterActiveOnly should be UserInterfaceOnly

Sub Tester5()
If ActiveSheet.ProtectContents _
Or ActiveSheet.ProtectDrawingObjects _
Or ActiveSheet.ProtectScenarios Then
On Error Resume Next
ActiveSheet.Unprotect password:=""
If Err.Number <> 0 Then
Err.Clear
MsgBox "Sheet is password protected"
Activesheet.Protect UserInterFaceOnly:=True
End If
On Error GoTo 0
End If


End Sub


--
Regards,
Tom Ogilvy



Tom Ogilvy said:
In xl2000 and earlier you can use the UserInteractiveOnly Property of the
protect method to work with the worksheet without knowing the password.

You can check if the sheet is protected with

Sub Tester5()
If ActiveSheet.ProtectContents _
Or ActiveSheet.ProtectDrawingObjects _
Or ActiveSheet.ProtectScenarios Then
On Error Resume Next
ActiveSheet.Unprotect password:=""
If Err.Number <> 0 Then
Err.Clear
MsgBox "Sheet is password protected"
Activesheet.Protect UserInteractiveOnly:=True
End If
On Error GoTo 0
End If


End Sub

In Excel 2002 and later, you would need to know the password.
 
Back
Top