MPW
Well-known Member
- Joined
- Oct 7, 2009
- Messages
- 571
- Office Version
- 365
- Platform
- Windows
Hi All,
I am using Excel (Office 2003).
I am trying to unprotect a vba project using sendkeys.
The trick to using the sendkeys is to make sure the right object is selected.
For this reason I can't step through the code because it will move the focus.
Basically, I am using a browse window to select the workbook to modify. I then open the workbook. Next I needed to unprotect the VBProject. At first I was using
but this did not work on every system.
So I thought when I want to edit a project I just click on the project in the "Project Explorer" so I thought I would try
I changed the ~ for {ENTER} so I could read it easier years later when I have to look at it again.
Again the results were spotty because I have more then 1 workbook open.
At this point I decided to use the workbook name that I all ready had trapped to open the workbook in the first place. I have tried a lot of different combinations with out any real success. I am using stuff from Chip Pearson's site (http://www.cpearson.com/excel/vbe.aspx). It seems to be the best resource on this subject.
I have several people using the Workbook I am trying to fix with this method.
They are in different countries all over the world so I can't easily fix them without making some kind of patch like this.
Please let me know if you have any insight on how to do it.
MPW
I am using Excel (Office 2003).
I am trying to unprotect a vba project using sendkeys.
The trick to using the sendkeys is to make sure the right object is selected.
For this reason I can't step through the code because it will move the focus.
Basically, I am using a browse window to select the workbook to modify. I then open the workbook. Next I needed to unprotect the VBProject. At first I was using
PHP:
"%{F11}TE(password)~~", True
So I thought when I want to edit a project I just click on the project in the "Project Explorer" so I thought I would try
PHP:
"%{F11}^R{TAB}{ENTER}(password){ENTER}", True
Again the results were spotty because I have more then 1 workbook open.
At this point I decided to use the workbook name that I all ready had trapped to open the workbook in the first place. I have tried a lot of different combinations with out any real success. I am using stuff from Chip Pearson's site (http://www.cpearson.com/excel/vbe.aspx). It seems to be the best resource on this subject.
PHP:
Dim VBAEditor As VBIDE.VBE
Dim VBProj As VBIDE.VBProject
Dim VBComp As VBIDE.VBComponent
Dim CodeMod As VBIDE.CodeModule
'I tried'
Workbooks(oldwrkbk.Name).VBProject.VBE.MainWindow.SetFocus
Workbooks(oldwrkbk.Name).VBProject.VBE.MainWindow.Select
'etc.'
I have several people using the Workbook I am trying to fix with this method.
They are in different countries all over the world so I can't easily fix them without making some kind of patch like this.
Please let me know if you have any insight on how to do it.
MPW