Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I'm using SendKeys to access various parts of a company intranet, input
usernames/passwords, move through various menus etc. Each subroutine works fine in itself but when I try to run them all together, I keep getting errors at the "AppActivate .....(2nd window)". But when run separately, this (second) macro works quite OK. I've tried to solve the problem by using: Appactivate "Microsoft Excel" at the end of the first subroutine in order to 'return' to the Excel window, but this doesn't seem to work either. What's causing the problem and how do I solve it? |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Try using the True parameter at the end of the statement, e.g.:
AppActivate "Microsoft Excel", True AppActivate "OtherApp", True (this forces VBA to wait until the calling app (your VBA routine in Excel) has the focus back before it activates the next one - sometimes the timing makes a difference on whether the app is ready to be activated yet. In practice I have found I need to figure this out by trial and error. -- - K Dales "Zakynthos" wrote: I'm using SendKeys to access various parts of a company intranet, input usernames/passwords, move through various menus etc. Each subroutine works fine in itself but when I try to run them all together, I keep getting errors at the "AppActivate .....(2nd window)". But when run separately, this (second) macro works quite OK. I've tried to solve the problem by using: Appactivate "Microsoft Excel" at the end of the first subroutine in order to 'return' to the Excel window, but this doesn't seem to work either. What's causing the problem and how do I solve it? |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Sendkeys is difficult to work with because the keys are not actually
executed until there is nothing else to do in the macro. So with this: Sub Demo() Application.SendKeys "Abcd", True Application.SendKeys "{Down}", True EnterNumber EnterNumber EnterNumber End Sub Sub EnterNumber() ActiveCell.Value = 123 ActiveCell.Offset(1).Select End Sub the "Abcd" is the last item entered by the macro even though it's first in the macro. I don't know whether this is a factor in what you're doing so just FYI. A DoEvents may help here. If you insert DoEvents after the second SendKeys above Abcd is entered first. Even so Sendkeys is never a really reliable answer. -- Jim "Zakynthos" wrote in message ... | I'm using SendKeys to access various parts of a company intranet, input | usernames/passwords, move through various menus etc. | | Each subroutine works fine in itself but when I try to run them all | together, I keep getting errors at the "AppActivate .....(2nd window)". But | when run separately, this (second) macro works quite OK. | | I've tried to solve the problem by using: | | Appactivate "Microsoft Excel" | | at the end of the first subroutine in order to 'return' to the Excel window, | but this doesn't seem to work either. | | What's causing the problem and how do I solve it? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
SendKeys syntax problem | New Users to Excel | |||
sendkeys problem | Excel Programming | |||
sendkeys problem for telnet | Excel Programming | |||
SendKeys problem | Excel Programming | |||
SendKeys and Path Problem | Excel Programming |