Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default 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
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
Stop a Procedure from another procedure Ayo Excel Discussion (Misc queries) 1 October 30th 08 02:42 AM
formula for % passing RKing Excel Worksheet Functions 2 August 30th 07 03:32 PM
Passing a UDF as an argument to a UDF puff Excel Discussion (Misc queries) 3 February 23rd 06 10:46 PM
Passing Variables Jeff Excel Discussion (Misc queries) 1 November 4th 05 07:46 PM


All times are GMT +1. The time now is 09:43 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"