- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我从 SAP 获得了一些数据,然后我按下了 SAP 的打印按钮以打印数据。
然后出现打印窗口:
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" _
(ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
(ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Const BM_CLICK = &HF5
'''
hWnd = FindWindow("#32770", "Print") 'LINE 1 comment;
Childhwnd = FindWindowEx(hWnd, ByVal 0&, "Button", "OK")';
'ON THIS LINE NEED TO INSERT CODE THAT CHANGES PRINTER NAME;
SendMessage Childhwnd, BM_CLICK, 0, ByVal 0& 'LINE 4 comment;
最佳答案
已解决的问题(适用于 Windows 10):
请注意,所需的代码是:
'Declarations
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Public Declare Function GetWindow Lib "user32" _
(ByVal hwnd As Long, ByVal wCmd As Long) As Long
Dim i 'index to the selected item
Dim getPrintName As String ' the text of the selected item
Dim getPrintNameLength As Long ' the length of the selected item's text
Dim printPDFFound As Boolean
Dim ChildhwndPrint11 As Long
Dim ChildhwndPrint1 As Long
Dim ChildhwndPrint As Long
Dim hwndPrint As Long
Const GW_CHILD = 5
Const GW_HWNDNEXT = 2
Const CB_GETLBTEXTLEN = &H149
Const CB_GETLBTEXT = &H148
getPrintName = Space(20)
'Code Between Previous Lines LINE1 and LINE4 Used To Change The Print Name
hwndPrint = hwnd
ChildhwndPrint = GetWindow(hwndPrint, GW_CHILD)
If ChildhwndPrint = 0 Then
MsgBox "ChildhwndPrint not found."
Exit Sub
End If
ChildhwndPrint1 = GetWindow(ChildhwndPrint, GW_HWNDNEXT)
If ChildhwndPrint1 = 0 Then
MsgBox "ChildhwndPrint1 not found."
Exit Sub
End If
ChildhwndPrint11 = GetWindow(ChildhwndPrint1, GW_HWNDNEXT)
If ChildhwndPrint11 = 0 Then
MsgBox "ChildhwndPrint11 not found."
Exit Sub
End If
Call SendMessage(ChildhwndPrint11, CB_SHOWDROPDOWN, True, 0)
i = 0
printPDFFound = False
'getPrintName = ""
Do Until (i = 30) Or (getPrintName = "Microsoft Print to PDF")
Call SendMessage(ChildhwndPrint11, CB_SETCURSEL, i, 0)
'Call SendMessage(ChildhwndPrint11, CB_GETLBTEXT, 2, buffer)
getPrintNameLength = SendMessage(ChildhwndPrint11, CB_GETLBTEXTLEN, ByVal CLng(i), ByVal CLng(0))
getPrintName = Space(getPrintNameLength) & vbNullChar
getPrintNameLength = SendMessage(ChildhwndPrint11, CB_GETLBTEXT, ByVal CLng(i), ByVal getPrintName)
getPrintName = Left(getPrintName, getPrintNameLength)
'MsgBox getPrintName
If getPrintName = "Microsoft Print to PDF" Then
printPDFFound = True
End If
i = i + 1
Loop
If printPDFFound = False Then
MsgBox "<Microsoft Print to PDF> print name was not found."
Exit Sub
End If
关于vba - 如何在 VBA 中更改打印机对话框的默认名称? (使用打印机对话框的句柄时),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48303411/
我设置了 Helm 柄和 Helm 柄。我有tiller-deploy。昨天,我可以定期运行了。但今天我收到此错误消息 Error: could not find a ready tiller pod
我以前已将分er安装到特定的 namespace 中。 我设置了一个环境变量来设置'tiller'命名空间-但我不记得该环境变量的名称-而且似乎无法通过网络搜索找到它。 这是什么 key ? 最佳答案
当我在 View 模型中使用如下界面时 class MainViewModel @ViewModelInject constructor( private val trafficImagesR
我正在尝试找到如何在某个 fragment 相关场景中定义 Hilt 的解决方案。我有以下设置: Activity 父 fragment 1 子 fragment 1 子 fragment 2 ...
Hilt 指出如果没有@Provides 注解就不能提供这个接口(interface): interface PlannedListRepository { fun getAllLists()
我的问题非常简单明了:两个注释/示例之间有什么区别: 例子一 @Singleton class MySingletonClass() {} @Module @InstallIn(FragmentCom
我是一名优秀的程序员,十分优秀!