VBA发送密钥 - 填充第三方对话框

时间:2015-11-21 05:21:42

标签: vba

我尝试在VBA(Word 2010)中使用SendKeys来填充某些第三方传真软件的对话框。下面的代码显示传真对话框,它有焦点,光标在我要发送数据的字段中闪烁。但实际上数据会被发送到Word文档(或代码编辑器 - 无论从哪里调用sub)。如何防止这种情况并填充对话框?

Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Sub RightFax()

With Dialogs(wdDialogFilePrintSetup)
    .Printer = "RightFax Fax Printer"
    .DoNotSetAsSysDefault = True
    .Execute
End With

SendKeys "{Enter}"

        Sleep 500                 'test - prints in word doc or code editor
            SendKeys "TEST AAA"
        Sleep 500

With Dialogs(wdDialogFilePrint)
    .Show
End With

        Sleep 500                 'test - prints in word doc or code editor
            SendKeys "TEST BBB"

End Sub

0 个答案:

没有答案