Nos, működik a dolog. Már csak egy kicsi szépséghiba van benne:
Hogyan lehet a Project Explorer ablakban egyértelműen azonosítani egy Projectet?
Sajnos a név begépelés csak a szóközig működik, aztán már csak pittyeg, és hát a szóközig mindegyiknek ugyan az a neve ("VBAProject").
A hivatkozott oldalon ez a programkód van:
Sub Gomb2_Kattintáskor()
Workbooks.Open "C:\Your\File\Path\YourFileName.xls"
With Application
'Go to the VBE
.SendKeys "%{F11}", True
'Activate Project Explorer window
.SendKeys "^r", True
.SendKeys "VBAProject" + Chr(32) + "(Próba.xls)"
'Tab your way to the workbook project
'Note - - when I tested this, it was in a separate workbook,
'following 6 add-in projects.
'"YourFileName" was the 8th project in my PE window,
'so 9 tab hits were required.
'You could also down-arrow using .SendKeys "{DOWN}", True
.SendKeys "{TAB}", True
.SendKeys "{TAB}", True
.SendKeys "{TAB}", True
.SendKeys "{TAB}", True
.SendKeys "{TAB}", True
.SendKeys "{TAB}", True
.SendKeys "{TAB}", True
.SendKeys "{TAB}", True
.SendKeys "{TAB}", True
'Simulate the Enter key
.SendKeys "~", True
'Enter your password - - this example is "Password"
.SendKeys "Blackout"
'Enter again
Password
.SendKeys "~", True
End With
End Sub
Itt TAB-okkal van megoldva a probléma, de nekem ez nem jó, mert nem ismert, hogy a program futtatásakor hány darab project fut és azok milyen sorrendben vannak.
Én jelenleg így alakítottam át a kódot, de a megfelelő project kiválasztása nem működik, erre keresek megoldást.
Sub Gomb2_Kattintáskor()
With Application
.SendKeys "%{F11}", True
.SendKeys "^r", True
.SendKeys "VBAProject" + Chr(32) + "(Próba.xls)" 'Sem így sem "VBAProject (Próba.xls)"-t beíva nem működik
.SendKeys "~", True
.SendKeys "Password"
.SendKeys "~", True
End With
End Sub
Üdv, vilag