ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   alt & f11 via macro (https://www.excelbanter.com/excel-programming/404618-alt-f11-via-macro.html)

pswanie

alt & f11 via macro
 
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


Matthew Pfluger

alt & f11 via macro
 
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

"pswanie" wrote:

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


pswanie

alt & f11 via macro
 
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..


"Matthew Pfluger" wrote:

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

"pswanie" wrote:

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


Matthew Pfluger

alt & f11 via macro
 
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

"pswanie" wrote:

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..




pswanie

alt & f11 via macro
 
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


"Matthew Pfluger" wrote:

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

"pswanie" wrote:

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..




Matthew Pfluger

alt & f11 via macro
 
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

"pswanie" wrote:

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


"Matthew Pfluger" wrote:

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

"pswanie" wrote:

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..




pswanie

alt & f11 via macro
 
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




"Matthew Pfluger" wrote:

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

"pswanie" wrote:

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


"Matthew Pfluger" wrote:

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

"pswanie" wrote:

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..




Matthew Pfluger

alt & f11 via macro
 
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

"pswanie" wrote:

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




"Matthew Pfluger" wrote:

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

"pswanie" wrote:

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


"Matthew Pfluger" wrote:

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

"pswanie" wrote:

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..




pswanie

alt & f11 via macro
 
tun-time error '91'

object variable or with block cariable not set

"Matthew Pfluger" wrote:

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

"pswanie" wrote:

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




"Matthew Pfluger" wrote:

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

"pswanie" wrote:

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


"Matthew Pfluger" wrote:

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

"pswanie" wrote:

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..




Matthew Pfluger

alt & f11 via macro
 
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

pswanie

alt & f11 via macro
 
i used a "clean" workbook and it worked...

will have a look and play around

much appreciated!!!!

thanx

Phillip

"Matthew Pfluger" wrote:

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


pswanie

alt & f11 via macro
 
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




Matthew Pfluger

alt & f11 via macro
 
Are you missing an "End if"?

"pswanie" wrote:

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




pswanie

alt & f11 via macro
 
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

"Matthew Pfluger" wrote:

Are you missing an "End if"?

"pswanie" wrote:

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




Matthew Pfluger

alt & f11 via macro
 
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

"pswanie" wrote:

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

"Matthew Pfluger" wrote:

Are you missing an "End if"?




All times are GMT +1. The time now is 10:34 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com