alt & f11 via macro

P

pswanie

i got this.

can i add a command so that when i click that it checks that in textbox1 i
got "mypass" and then run the sub

and in that sub add a command to go to the editor ("alt" & "f11")



Private Sub CommandButton5_Click()


Application.Visible = True
Unload UserForm1


End Sub
 
M

Matthew Pfluger

Hello,

Try this:

Sub test()

' Get text box
ActiveSheet.Shapes("Text Box 1").Select

If Selection.Characters.Text = "MyPass" Then
' run sub

' Show VBE window
Application.VBE.ActiveCodePane.Show
End If

' Deselect text box
ActiveCell.Activate

End Sub

HTH,
Matthew Pfluger
 
P

pswanie

i have the said textbox on a userform. the aplication (excell workbook) is
set to visible = valse

now if i enter "mypass" in the textbox it enable commandbutton1.

commandbutton1_click make the application visible = true and unload userform1.

then i can get to my macros etc..
 
M

Matthew Pfluger

Okay, then change this:

ActiveSheet.Shapes("Text Box 1").Select
If Selection.Characters.Text = "MyPass" Then

to

If Me.TextBox1.Text = "MyPass" Then

Does that work for you?
Matthew Pfluger
 
P

pswanie

jip...
thanx (i did repost. didnt know if u got it flaged for notify of replies...)

do u know how to get the (alt & F11) key stroke by code in that?

if pass = my pass
then alt & f11 key stroke and rest of code
 
M

Matthew Pfluger

pswanie,

In my original post, the code:

Application.VBE.ActiveCodePane.Show

will do the same thing as Alt+F11. You can also use the SendKeys method:

Application.SendKeys ("%{F11}") where % stands for ALT. See the help files.

Matthew Pfluger
 
P

pswanie

run-time error '1004'
programmatic access to visual basic project is not trusted

i dont have a password on my codes (tools, vba properties, protection) but
might use one later

and the other way just open the worksheet like normal not the code side
 
M

Matthew Pfluger

Ah, sorry about that security setting. You will need to go to
Tools-->Macro-->Security and go to the Trusted Publishers tab and check the
two checkboxes at the bottom of the form. That should solve your problem.

Matthew Pfluger
 
M

Matthew Pfluger

Hmm, not sure why that is. Can you try this ultra-simple macro below? With
those two security settings checked, you shouldn't have any problems with
this. Otherwise, I'm not sure.

Sub test()
Application.VBE.ActiveCodePane.Show
End Sub

Matthew Pfluger
 
P

pswanie

i used a "clean" workbook and it worked...

will have a look and play around

much appreciated!!!!

thanx

Phillip
 
P

pswanie

this is what i got and what im using...

i tried moving that one line up/down but with no luck. somewhere it said
something about a with. but that did not work either

Private Sub CommandButton5_Click()

If Me.TextBox55.Value = "b" Then

Application.Visible = True
Application.VBE.ActiveCodePane.Show
Unload UserForm1

Else


MsgBox " This part is restricted" & vbNewLine & _
"Password required/Invalid Password" & vbNewLine & vbNewLine
& _
" Please retry"
End If

End Sub
 
P

pswanie

wait.... i think it does not set focus to the worksheet when i get to unload
userform1. how would i "select/set focus" to my worksheet after that line.

then application.vbe etc
 
M

Matthew Pfluger

Application.ScreenUpdating = True
ThisWorkbook.Sheets("SheetName").Activate

That may solve your problem, but I'm not sure. You shouldn't have to set
focus to the worksheet before activating the VBE.

Matthew Pfluger
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top