追加问题电脑锁屏时vba复制数据,不能到SAP怎么解决
下面使用sendmessage需要怎么修改?
#End If
Private Declare PtrSafe Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As LongPtr, ByVal wMsg As Long, ByVal wParam As LongPtr, lParam As Any) As LongPtr
Private Declare PtrSafe Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As LongPtr
Private Declare PtrSafe Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As LongPtr, ByVal hWnd2 As LongPtr, ByVal lpsz1 As String, ByVal lpsz2 As String) As LongPtr
Private Const WM_PASTE = &H302
Sub PasteDataToSAP()
Dim hh As Long
Dim hwnd As LongPtr
hh = Range("a2").CurrentRegion.Rows.Count
hwnd = FindWindow(543690, "Multiple Selection for Change Number") ' 将"SAP窗口标题"替换为实际的窗口标题
Range("a2:a" & hh).Copy
session.findById("wnd[0]").maximize
session.findById("wnd[0]/tbar[0]/okcd").Text = "/NSE16"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/ctxtDATABROWSE-TABLENAME").Text = "AEOI"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/btn%_I1_%_APP_%-VALU_PUSH").press
Dim hwndEdit As LongPtr
hwndEdit = FindWindowEx(hwnd, 0, "SAP_FRONTEND_SESSION", vbNullString)
SendMessage hwndEdit, WM_PASTE, 0, 0 ' 使用SendMessage函数进行粘贴操作