[英]Bring newly created Outlook appointment window in front
Is there any way to bring newly created Outlook appointment window in front to use Sendkeys functions? 有什么方法可以将新创建的Outlook约会窗口置于前面以使用Sendkeys函数? I am creating new appointment from Excel, copying data from workbook to body and modifying appointment to Skype meeting by sending keys. 我正在用Excel创建新约会,将数据从工作簿复制到正文,并通过发送密钥将约会修改为Skype会议。 However sometimes appointment opens behind Excel and SendKeys operation does not work. 但是,有时约会在Excel后面打开,SendKeys操作不起作用。
I have tried to use AppActivate
but I guess I am doing in the wrong way as debugger says Invalid procedure call or argument
. 我尝试使用AppActivate
但是我想我做错了,因为调试器说Invalid procedure call or argument
。 Also alternatives are welcomed. 也欢迎替代方案。
I have also tried, but it did not work all the time and sometimes appointment window opened in background anyway: 我也尝试过,但是它一直都无法正常工作,有时约会窗口仍然在后台打开:
Declare PtrSafe Function SetForegroundWindow Lib "user32" (ByVal hwnd As Long) As Long
.....
Dim olAppt As Outlook.AppointmentItem
Dim HWNDSrc As Long
.....
Set olAppt = olApp.CreateItem(olAppointmentItem)
SetForegroundWindow HWNDSrc
.....
Here is my full code: 这是我的完整代码:
Sub CreateNewOutlookAppointment()
Dim olApp As Outlook.Application
Dim olAppt As Outlook.AppointmentItem
Set olAppt = Nothing
Set olApp = Outlook.Application
Set olAppt = olApp.CreateItem(olAppointmentItem)
AppActivate olApp
With olAppt
.Subject = "Bid review" & ", " & ThisWorkbook.Sheets("Other Data").Range("P23").Value
ThisWorkbook.Sheets("Templates").Range("M202:M223").Copy
.Display
.GetInspector.WordEditor.Windows(1).Selection.PasteAndFormat wdPASTERTF
End With
Application.SendKeys ("%HOM")
Set olAppt = Nothing
End Sub
尝试调用Inspector.Activate
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.