Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,646
Default SendKeys "%{F11}", True

Hi All,

I tried to use (in XL2003)

SendKeys "%{F11}", True

to open VBE window, but it had no effect. In fact my real aim was

SendKeys "%{F11}%TE+{TAB}{RIGHT}%V{+}{TAB}" & Password & "{TAB}" & Password
& "~%{F11}", True

to set VBA project password. I found out that "%{F11}" part doesn't work. If
I previously open VBE window manually with Alt+F11, the remaining part sets
the password. Any advice?

Thanks,
Stefi

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default SendKeys "%{F11}", True

Stefi,

Try code like:

Sub OpenVBProject(WB As Workbook)
Dim VBProj As Object
Dim N As Long
N = 0
With Application.VBE
.MainWindow.Visible = True
For Each VBProj In .VBProjects
N = N + 1
If VBProj.Filename = WB.FullName Then
Set .ActiveVBProject = .VBProjects(N)
SendKeys "{ENTER}"
SendKeys "aa" '<<< YOUR PASSWORD
SendKeys "{ENTER}"
Exit For
End If
End With
Next VBProj
End Sub


You call this from a procedure as:

OpenVBProject Workbooks("Book123.xls")


--
Cordially,
Chip Pearson
Microsoft MVP - Excel, 10 Years
Pearson Software Consulting
www.cpearson.com
(email on the web site)


"Stefi" wrote in message
...
Hi All,

I tried to use (in XL2003)

SendKeys "%{F11}", True

to open VBE window, but it had no effect. In fact my real aim was

SendKeys "%{F11}%TE+{TAB}{RIGHT}%V{+}{TAB}" & Password & "{TAB}" &
Password
& "~%{F11}", True

to set VBA project password. I found out that "%{F11}" part doesn't work.
If
I previously open VBE window manually with Alt+F11, the remaining part
sets
the password. Any advice?

Thanks,
Stefi


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,646
Default SendKeys "%{F11}", True

Thanks Chip, I immediately start testing, I'll post the result'
Stefi


€˛Chip Pearson€¯ ezt Ć*rta:

Stefi,

Try code like:

Sub OpenVBProject(WB As Workbook)
Dim VBProj As Object
Dim N As Long
N = 0
With Application.VBE
.MainWindow.Visible = True
For Each VBProj In .VBProjects
N = N + 1
If VBProj.Filename = WB.FullName Then
Set .ActiveVBProject = .VBProjects(N)
SendKeys "{ENTER}"
SendKeys "aa" '<<< YOUR PASSWORD
SendKeys "{ENTER}"
Exit For
End If
End With
Next VBProj
End Sub


You call this from a procedure as:

OpenVBProject Workbooks("Book123.xls")


--
Cordially,
Chip Pearson
Microsoft MVP - Excel, 10 Years
Pearson Software Consulting
www.cpearson.com
(email on the web site)


"Stefi" wrote in message
...
Hi All,

I tried to use (in XL2003)

SendKeys "%{F11}", True

to open VBE window, but it had no effect. In fact my real aim was

SendKeys "%{F11}%TE+{TAB}{RIGHT}%V{+}{TAB}" & Password & "{TAB}" &
Password
& "~%{F11}", True

to set VBA project password. I found out that "%{F11}" part doesn't work.
If
I previously open VBE window manually with Alt+F11, the remaining part
sets
the password. Any advice?

Thanks,
Stefi


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,646
Default SendKeys "%{F11}", True

Hi Chip,

I found that this form works:

Sub OpenVBProject(WB As Workbook)
Dim VBProj As Object
Dim N As Long
N = 0
Password = "test"
With Application.VBE
.MainWindow.Visible = True
For Each VBProj In .VBProjects
N = N + 1
If VBProj.Filename = WB.FullName Then
Set .ActiveVBProject = .VBProjects(N)
SendKeys "%TE+{TAB}{RIGHT}%V{TAB}" & Password & "{TAB}" &
Password & "~", True
Exit For
End If
Next VBProj
.MainWindow.Visible = False
End With
End Sub

There is a minor question remained: I couldn't make it work when started
OpenVBProject via a hot key (say Ctrl+t). Do you have any explanation?

Many thanks anyway!

Regards,
Stefi


€˛Chip Pearson€¯ ezt Ć*rta:

Stefi,

Try code like:

Sub OpenVBProject(WB As Workbook)
Dim VBProj As Object
Dim N As Long
N = 0
With Application.VBE
.MainWindow.Visible = True
For Each VBProj In .VBProjects
N = N + 1
If VBProj.Filename = WB.FullName Then
Set .ActiveVBProject = .VBProjects(N)
SendKeys "{ENTER}"
SendKeys "aa" '<<< YOUR PASSWORD
SendKeys "{ENTER}"
Exit For
End If
End With
Next VBProj
End Sub


You call this from a procedure as:

OpenVBProject Workbooks("Book123.xls")


--
Cordially,
Chip Pearson
Microsoft MVP - Excel, 10 Years
Pearson Software Consulting
www.cpearson.com
(email on the web site)


"Stefi" wrote in message
...
Hi All,

I tried to use (in XL2003)

SendKeys "%{F11}", True

to open VBE window, but it had no effect. In fact my real aim was

SendKeys "%{F11}%TE+{TAB}{RIGHT}%V{+}{TAB}" & Password & "{TAB}" &
Password
& "~%{F11}", True

to set VBA project password. I found out that "%{F11}" part doesn't work.
If
I previously open VBE window manually with Alt+F11, the remaining part
sets
the password. Any advice?

Thanks,
Stefi


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default SendKeys "%{F11}", True


Do you have any explanation?


Nothing beyond that SendKeys is very unreliable. I would never use it in
commercial code.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel, 10 Years
Pearson Software Consulting
www.cpearson.com
(email on the web site)


"Stefi" wrote in message
...
Hi Chip,

I found that this form works:

Sub OpenVBProject(WB As Workbook)
Dim VBProj As Object
Dim N As Long
N = 0
Password = "test"
With Application.VBE
.MainWindow.Visible = True
For Each VBProj In .VBProjects
N = N + 1
If VBProj.Filename = WB.FullName Then
Set .ActiveVBProject = .VBProjects(N)
SendKeys "%TE+{TAB}{RIGHT}%V{TAB}" & Password & "{TAB}" &
Password & "~", True
Exit For
End If
Next VBProj
.MainWindow.Visible = False
End With
End Sub

There is a minor question remained: I couldn't make it work when started
OpenVBProject via a hot key (say Ctrl+t). Do you have any explanation?

Many thanks anyway!

Regards,
Stefi


€˛Chip Pearson€¯ ezt Ć*rta:

Stefi,

Try code like:

Sub OpenVBProject(WB As Workbook)
Dim VBProj As Object
Dim N As Long
N = 0
With Application.VBE
.MainWindow.Visible = True
For Each VBProj In .VBProjects
N = N + 1
If VBProj.Filename = WB.FullName Then
Set .ActiveVBProject = .VBProjects(N)
SendKeys "{ENTER}"
SendKeys "aa" '<<< YOUR PASSWORD
SendKeys "{ENTER}"
Exit For
End If
End With
Next VBProj
End Sub


You call this from a procedure as:

OpenVBProject Workbooks("Book123.xls")


--
Cordially,
Chip Pearson
Microsoft MVP - Excel, 10 Years
Pearson Software Consulting
www.cpearson.com
(email on the web site)


"Stefi" wrote in message
...
Hi All,

I tried to use (in XL2003)

SendKeys "%{F11}", True

to open VBE window, but it had no effect. In fact my real aim was

SendKeys "%{F11}%TE+{TAB}{RIGHT}%V{+}{TAB}" & Password & "{TAB}" &
Password
& "~%{F11}", True

to set VBA project password. I found out that "%{F11}" part doesn't
work.
If
I previously open VBE window manually with Alt+F11, the remaining part
sets
the password. Any advice?

Thanks,
Stefi





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,646
Default SendKeys "%{F11}", True

Well, I made it work via a Commandbutton. I would negligate using Sendkeys
with pleasure, but how else could I achieve my aim (setting VBA project
password)?

Thanks for your assistance!

Best regards,
Stefi

€˛Chip Pearson€¯ ezt Ć*rta:


Do you have any explanation?


Nothing beyond that SendKeys is very unreliable. I would never use it in
commercial code.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel, 10 Years
Pearson Software Consulting
www.cpearson.com
(email on the web site)


"Stefi" wrote in message
...
Hi Chip,

I found that this form works:

Sub OpenVBProject(WB As Workbook)
Dim VBProj As Object
Dim N As Long
N = 0
Password = "test"
With Application.VBE
.MainWindow.Visible = True
For Each VBProj In .VBProjects
N = N + 1
If VBProj.Filename = WB.FullName Then
Set .ActiveVBProject = .VBProjects(N)
SendKeys "%TE+{TAB}{RIGHT}%V{TAB}" & Password & "{TAB}" &
Password & "~", True
Exit For
End If
Next VBProj
.MainWindow.Visible = False
End With
End Sub

There is a minor question remained: I couldn't make it work when started
OpenVBProject via a hot key (say Ctrl+t). Do you have any explanation?

Many thanks anyway!

Regards,
Stefi


€˛Chip Pearson€¯ ezt Ć*rta:

Stefi,

Try code like:

Sub OpenVBProject(WB As Workbook)
Dim VBProj As Object
Dim N As Long
N = 0
With Application.VBE
.MainWindow.Visible = True
For Each VBProj In .VBProjects
N = N + 1
If VBProj.Filename = WB.FullName Then
Set .ActiveVBProject = .VBProjects(N)
SendKeys "{ENTER}"
SendKeys "aa" '<<< YOUR PASSWORD
SendKeys "{ENTER}"
Exit For
End If
End With
Next VBProj
End Sub


You call this from a procedure as:

OpenVBProject Workbooks("Book123.xls")


--
Cordially,
Chip Pearson
Microsoft MVP - Excel, 10 Years
Pearson Software Consulting
www.cpearson.com
(email on the web site)


"Stefi" wrote in message
...
Hi All,

I tried to use (in XL2003)

SendKeys "%{F11}", True

to open VBE window, but it had no effect. In fact my real aim was

SendKeys "%{F11}%TE+{TAB}{RIGHT}%V{+}{TAB}" & Password & "{TAB}" &
Password
& "~%{F11}", True

to set VBA project password. I found out that "%{F11}" part doesn't
work.
If
I previously open VBE window manually with Alt+F11, the remaining part
sets
the password. Any advice?

Thanks,
Stefi



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default SendKeys "%{F11}", True

Unfortunately, there is no programmatic way to modify the security settings
of a VBProject. You can test the setting but not unlock the project.
SendKeys, as poor as it is, is the only way to do it.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel, 10 Years
Pearson Software Consulting
www.cpearson.com
(email on the web site)


"Stefi" wrote in message
...
Well, I made it work via a Commandbutton. I would negligate using Sendkeys
with pleasure, but how else could I achieve my aim (setting VBA project
password)?

Thanks for your assistance!

Best regards,
Stefi

€˛Chip Pearson€¯ ezt Ć*rta:


Do you have any explanation?


Nothing beyond that SendKeys is very unreliable. I would never use it in
commercial code.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel, 10 Years
Pearson Software Consulting
www.cpearson.com
(email on the web site)


"Stefi" wrote in message
...
Hi Chip,

I found that this form works:

Sub OpenVBProject(WB As Workbook)
Dim VBProj As Object
Dim N As Long
N = 0
Password = "test"
With Application.VBE
.MainWindow.Visible = True
For Each VBProj In .VBProjects
N = N + 1
If VBProj.Filename = WB.FullName Then
Set .ActiveVBProject = .VBProjects(N)
SendKeys "%TE+{TAB}{RIGHT}%V{TAB}" & Password & "{TAB}"
&
Password & "~", True
Exit For
End If
Next VBProj
.MainWindow.Visible = False
End With
End Sub

There is a minor question remained: I couldn't make it work when
started
OpenVBProject via a hot key (say Ctrl+t). Do you have any explanation?

Many thanks anyway!

Regards,
Stefi


€˛Chip Pearson€¯ ezt Ć*rta:

Stefi,

Try code like:

Sub OpenVBProject(WB As Workbook)
Dim VBProj As Object
Dim N As Long
N = 0
With Application.VBE
.MainWindow.Visible = True
For Each VBProj In .VBProjects
N = N + 1
If VBProj.Filename = WB.FullName Then
Set .ActiveVBProject = .VBProjects(N)
SendKeys "{ENTER}"
SendKeys "aa" '<<< YOUR PASSWORD
SendKeys "{ENTER}"
Exit For
End If
End With
Next VBProj
End Sub


You call this from a procedure as:

OpenVBProject Workbooks("Book123.xls")


--
Cordially,
Chip Pearson
Microsoft MVP - Excel, 10 Years
Pearson Software Consulting
www.cpearson.com
(email on the web site)


"Stefi" wrote in message
...
Hi All,

I tried to use (in XL2003)

SendKeys "%{F11}", True

to open VBE window, but it had no effect. In fact my real aim was

SendKeys "%{F11}%TE+{TAB}{RIGHT}%V{+}{TAB}" & Password & "{TAB}" &
Password
& "~%{F11}", True

to set VBA project password. I found out that "%{F11}" part doesn't
work.
If
I previously open VBE window manually with Alt+F11, the remaining
part
sets
the password. Any advice?

Thanks,
Stefi




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
change "true" and "false" to "availble" and "out of stock" inthestands Excel Worksheet Functions 2 July 19th 07 07:05 PM
SendKeys "{F},true does not work clara Excel Worksheet Functions 0 June 18th 07 08:49 PM
Typing "true" excel 2007 change it to "TRUE" Mr. T Excel Discussion (Misc queries) 2 April 11th 07 01:24 PM
Count occurences of "1"/"0" (or"TRUE"/"FALSE") in a row w. conditions in the next BCB New Users to Excel 7 May 13th 06 10:02 PM
IF(VLOOKUP("MYDATA", MYNAME, 4) = 0, "TRUE", "FALSE") Souris Excel Programming 2 August 17th 05 05:33 AM


All times are GMT +1. The time now is 01:37 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"