Private Const sw_restore = 9
#If VBA7 Then
Private Declare PtrSafe Function showwindow Lib "user32" (ByVal hwnd As Long, ByVal ncmdshow As Long) As Long
Private Declare PtrSafe Function isiconic Lib "user32.dll" (ByVal hwnd As Long) As Long
#Else
Private Declare Function showwindow Lib "user32" (ByVal hwnd As Long, ByVal ncmdshow As Long) As Long
Private Declare Function isiconic Lib "user32.dll" (ByVal hwnd As Long) As Long
#End If
Sub openProgram()
Dim strDirectory As String
Dim pID As Variant, sh As Variant
strDirectory = "H:\LocalStorage\Program.exe"
Set sh = CreateObject("shell.application")
For Each w In sh.Windows
If w.document.folder.self.Path = strDirectory Then
If CBool(isiconic(w.hwnd)) Then
w.Visible = False
w.Visible = True
End If
Exit Sub
End If
Next
pID = Shell("H:\LocalStorage\Program.exe", vbNormalFocus)
waittime 3000
Application.SendKeys "{Right}", True
waittime 3000
Application.SendKeys "{Right}", True
waittime 3000
Application.SendKeys "{Right}", True
waittime 3000
Application.SendKeys "{Right}", True
waittime 3000
Application.SendKeys "{Right}", True
waittime 3000
Application.SendKeys "{Right}", True
waittime 3000
Application.SendKeys "{Right}", True
waittime 3000
Application.SendKeys "{Right}", True
waittime 3000
Application.SendKeys "{%}", True
End Sub
Function waittime(ByVal milliseconds As Double)
Application.Wait (Now() + milliseconds / 24 / 60 / 60 / 1000)
End Function
我需要{%}或{END}键才能在程序中注册,以跳至下一行选项。要继续进行两次,然后在“报告”上按Enter。然后向下几次创建新报告。然后继续使用粗略且不可靠的sendkey,直到我可以自动执行每周需要运行的每个报表。节省一些时间。我宁愿使用比sendkey更健壮的功能。还有其他可行的选择吗?谢谢