![]() |
Select specific Project in VBA
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 |
Select specific Project in VBA
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("Fir st").CodeModule.CodePane -- Cordially, Chip Pearson Microsoft MVP - Excel www.cpearson.com (email address is on the web site) "Noemi" wrote in message ... 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 |
Select specific Project in VBA
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).CodeModu le.CodePane End With -- Cordially, Chip Pearson Microsoft MVP - Excel www.cpearson.com (email address is on the web site) "Chip Pearson" wrote in message ... 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("Fir st").CodeModule.CodePane -- Cordially, Chip Pearson Microsoft MVP - Excel www.cpearson.com (email address is on the web site) "Noemi" wrote in message ... 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 |
Select specific Project in VBA
Chip
Thank you so much, it worked. Thanks Noemi "Chip Pearson" wrote: 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).CodeModu le.CodePane End With -- Cordially, Chip Pearson Microsoft MVP - Excel www.cpearson.com (email address is on the web site) "Chip Pearson" wrote in message ... 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("Fir st").CodeModule.CodePane -- Cordially, Chip Pearson Microsoft MVP - Excel www.cpearson.com (email address is on the web site) "Noemi" wrote in message ... 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 |
All times are GMT +1. The time now is 05:24 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com