PDA

View Full Version : Solved: Help needed with VBA for Alt+F11



Gil
04-29-2010, 04:57 AM
Hello
I have a userform with a command button on it. I want to be able to open the vba editor from this button. I tried to record a macro that would record the keystrokes Alt+F11 but that didn't work. Had a search of the net and can't find a solution, any suggestions gratefully received.
Gil

xld
04-29-2010, 05:10 AM
Application.VBE.MainWindow.Visible = True

Gil
04-29-2010, 05:40 AM
Hello xld
Thank you for your reply. I have attached a workbook with your code in the command button. When pressed the following error comes up

Run-time error '1004':
Programatic access to Visual Basic Project is not trusted

Gil

xld
04-29-2010, 06:57 AM
You have to trust access to projects to use this approach, Tools>Macros>Security...>Trusted Publishers, and check the bottom box.

Gil
04-29-2010, 08:15 AM
Hello xld
Many thanks for that answer which applies to 2003. I think I am in the fortunate position where I have 2003 on my laptop and 2007 on my pc.
Where is that 'Trusted Publishers' located in 2007.
I have looked in Developer/ Macro Security/Trusted Publishers and that is blank.
Gil

Gil
04-29-2010, 08:36 AM
Hello Me
I think I have found the solution for myself.
Go to
Developer/Macro Security/Trusted Locations/Add New Location
e.g. F:\Documents and Settings\The long winded mapper\open tool\
then choose Macro Settings and tick 'Trust access to the VBA project object model'
It works
Gil

Aussiebear
04-30-2010, 03:27 AM
There are times when the difference between 2003 & 2007 is so similar that if you follow the concept offered, a solution can be found. Whilst VBA Express is a learning website, we do expect those asking for assistance to have a go at the work themselves. I'm glad you have followed this concept