Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Passing a Password to a VBA Procedure
Hi Randy,
Set Application.VBE.ActiveProject = strUpdateWB.VBProject I think your above statement isn't correct, because Set Statement assigns an object reference to a variable or property. And its syntax is: Set objectvar = {[New] objectexpression | Nothing}, where objectvar is a name of the variable or property, not an object like you did. There isn't AcitveProject property, maybe you want to use ActiveVBProject Property HTH --- Orlando Magalhães Filho (So that you get best and rapid solution and all may benefit from the discussion, please reply within the newsgroup, not in email) "Randy" escreveu na mensagem om... I'm trying to insert a few lines of code into a VBA procedure that I wrote and distributed to various users. I protected this code so that nobody could go in and make changes without knowing the password. Now, I want to add a control button to their Excel file and link a few simple lines of code to the button. I'm trying to use the SendKeys command to bypass the password protection. On the following line, I get the error message "Object doesn't support this property or method": Set Application.VBE.ActiveProject = strUpdateWB.VBProject I can't seem to determine why this won't work. Any ideas? Here is the code (boiled down to only the relevant lines): Sub AddButton() Dim strUpdateWB As Workbook Dim OLEObj As OLEObject Dim MySheet As Worksheet Windows("Standard Template Version 3.xls").Activate Set strUpdateWB = ThisWorkbook Set MySheet = Worksheets("Balance Sheet") 'create the button Set OLEObj = MySheet.OLEObjects.Add(ClassType:="Forms.CommandBu tton.1", _ Left:=415, Top:=9.75, Width:=100, Height:=20) OLEObj.Name = "UpdateLinks" OLEObj.Object.Caption = "Update Links" 'Pass the password to the VBA project so that it can be modified Set Application.VBE.ActiveProject = strUpdateWB.VBProject Application.SendKeys ("~gold~") 'Create the event procedure With ThisWorkbook.VBProject.VBComponents(OLEObj.Parent. Name).CodeModule .InsertLines .CreateEventProc("Click", OLEObj.Name) + 1, _ "Msgbox ""You Clicked The Button"" " End With End Sub TIA Randy Eastland |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Stop a Procedure from another procedure | Excel Discussion (Misc queries) | |||
formula for % passing | Excel Worksheet Functions | |||
Passing a UDF as an argument to a UDF | Excel Discussion (Misc queries) | |||
Passing Variables | Excel Discussion (Misc queries) |