Anyone know how to send Ctl + G to Outlook from a vb project?
I really dont want to be using VBA or the SendKeys function.
:(
Thanks in advance.
Printable View
Anyone know how to send Ctl + G to Outlook from a vb project?
I really dont want to be using VBA or the SendKeys function.
:(
Thanks in advance.
Sice I cannot test, what's CTL+G in Outlook?
Under the Calendar display the menu will change so if you press Ctl + G you will get the
Go To Date... dialog box.
This will display that days appointments.
Also, you can go there by clicking on "View - Go To - Go To Date..."
I guess it doesn't matter what your sending and to where
I just need to figure it out, so any example should do just fine.
AppActivate "Outlook"
' NOTE Above statement will NOT work. Outlook changes its title, depending on what folder is selected.
SendKeys "^g"
There is also an API that does something similar to SendKeys - but I don't use it / know it.
The alternative is to call Outlook from your VB program, and either get your program to display the information you want, or ask Outlook (typically via <SomeObject>.DISPLAY) to dispay it for you.
What about finding the process ID of Outlook by going through
the task manager with some APIs and then using the
FindWindowEx API then using the SendMessage API?
Outlook is always listed in the task manager as "OUTLOOK.EXE"
I have coded finding a process before by name, but I havent used the
FindWindowEx or SendMessage APIs.
Any Help on these?
I don't know if I will include everything needed, but here is some extracts that I use to ENUM through open Windows, and identify which one is Outlook:
VB Code:
' ' Declarations to handle "What was the last app used?" ' Private Declare Function IsWindowVisible Lib "user32" (ByVal hwnd As Long) As Long Public Declare Function EnumWindows Lib "user32" (ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long Public Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long Declare Function GetParent Lib "user32" (ByVal hwnd As Long) As Long Declare Function GetClassName Lib "user32" Alias "GetClassNameA" _ (ByVal hwnd As Long, ByVal lpClassName As String, _ ByVal nMaxCount As Long) As Long Public Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long Public thisHwnd As Long Public LastApp As Long Public LastAppTitle As String Public LastAppClass As String Public Declare Function GetActiveWindow Lib "user32" () As Long Public Const WM_CLOSE = &H10 Public Const INFINITE = &HFFFFFFFF ' ' Now some code to use them ' Public Function WhoCalledUs() thisHwnd = GetActiveWindow() LastApp = 0 Call EnumWindows(AddressOf EnumWinProc, 0) Select Case LastAppClass Case "OpusApp" WhoCalledUs = "Word" Case "XLMAIN" WhoCalledUs = "Excel" Case "rctrl_renwnd32" WhoCalledUs = "Outlook" Case "ExploreWClass" WhoCalledUs = "WinExp" Case "PP9FrameClass" WhoCalledUs = "PPT" Case Else WhoCalledUs = "" End Select End Function Public Function EnumWinProc(ByVal hwnd As Long, ByVal lParam As Long) As Long Dim lRet, lWindowStyle, lWindowParent As Long Dim strBuffer As String 'Only keep windows that are visible, ' don't have parents, have a title bar and a caption, ' and are not this application, and are the first application found If hwnd <> thisHwnd Then ' Not this app If IsWindowVisible(hwnd) Then ' Window visible lWindowParent = GetParent(hwnd) If lWindowParent = 0 Then ' No parents lWindowStyle = GetWindowLong(hwnd, GWL_STYLE) If (lWindowStyle And WS_CAPTION) Then ' Has a caption strBuffer = Space(MAX_LEN) lRet = GetWindowText(hwnd, strBuffer, Len(strBuffer)) If lRet Then ' Has a title If LastApp = 0 Then LastApp = hwnd LastAppTitle = Left(strBuffer, InStr(strBuffer, Chr(0)) - 1) strBuffer = Space(MAX_LEN) lRet = GetClassName(hwnd, strBuffer, MAX_LEN) LastAppClass = Left(strBuffer, InStr(strBuffer, Chr(0)) - 1) End If End If End If End If End If End If EnumWinProc = 1 End Function