Select specific Project in VBA

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi
I want to create code using the sendkeys( I know they are not very realiable
but this is all I can do) to remove the project protection off a certain
project however I am not sure how to select the project via sendkeys.

We have multiple hiden sheets which are avilable in VBA but I need to select
one called First.

Any idea how to do this.

Thanks
Noemi
 
Noemi,

Try something

Set Application.VBE.ActiveVBProject = Workbooks("Book1.xls").VBProject

This will select the Book1.xls project in the VBE. You can't make a
components active if the project is locked. Once you've unlocked the
project, you can make a component active with

Set Application.VBE.ActiveCodePane = _
Workbooks("Book4.xls").VBProject.VBComponents("First").CodeModule.CodePane


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
www.cpearson.com
(email address is on the web site)
 
I should have added that in the second line of code "first" refers to the
CodeName of the worksheet, not the name of the worksheet as shown in the
tabs. If you need to use the tab name, use code like


With Workbooks("Book4.xls").Worksheets("TabName")
Set Application.VBE.ActiveCodePane = _
.Parent.VBProject.VBComponents(.CodeName).CodeModule.CodePane
End With


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
www.cpearson.com
(email address is on the web site)
 
Chip
Thank you so much, it worked.

Thanks
Noemi

Chip Pearson said:
I should have added that in the second line of code "first" refers to the
CodeName of the worksheet, not the name of the worksheet as shown in the
tabs. If you need to use the tab name, use code like


With Workbooks("Book4.xls").Worksheets("TabName")
Set Application.VBE.ActiveCodePane = _
.Parent.VBProject.VBComponents(.CodeName).CodeModule.CodePane
End With


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
www.cpearson.com
(email address is on the web site)
 
Back
Top