'Excel w/vba Program not coming to foreground at PC start Windows10 touchscreen
I have a windows10 pc with a touchscreen and no keyboard or mouse. I have an excel program that I want to start up everytime the pc is restarted. I used shell:startup to place a shortcut for the file in the folder and the system will start and open the file but it is in the background. I can click it from the tablet menu and it opens but i would like it to come to the foreground by itself. I did some testing and setup the exact same file into a nontouch screen laptop and the file opens perfect. Here is a sample of the simple vba code running on the file and some code I have tried to make it come to the foreground.
private Sub Workbook_Open()
Application.Caption = "Test System"
Application.Wait (Now + 0.0001)
'SendKeys "%{Tab}", True
'ActiveWindow.Visible = True
MsgBox "System Restarting", vbcritcal + vbSystemModal
End Sub
the two comment lines I have tried to make the program come to the foreground but they did not help, I tried them one at a time .
Solution 1:[1]
AppActivate will do the job for you like so:
AppActivate ThisWorkbook.Windows(1).Caption
You said that this was happening right after a restart, so ThisWorkbook.Windows should only have that 1 member in it. Alternatively, you can give the name of the window to the command like this:
AppActivate "Book1 - Excel".
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | TehDrunkSailor |
