Reputation: 11
I wrote the application to Outlook in VBA and now I want to write it again in VB.net (to make it independent application). I have specific problem I couldn't find answer for - to navigate in outlook explorer I wrote procedure, which activates explorer, sends key down and activates form again. When I start application in Visual Studio this procedure works perfectly, but when I close VS and run single exe, Outlook explorer doesn't activate - it's only blinking on taskbar, then sendkey doesn't work and next email is not selected. Here is the code:
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim app As Type = Type.GetTypeFromProgID("Outlook.Application")
Dim oApp As Object = Activator.CreateInstance(app)
oApp.ActiveExplorer.Activate()
SendKeys.Send("{Down}")
Me.Activate()
End Sub
Can anyone help me with this?
Upvotes: 0
Views: 3641
Reputation: 11
I did it with code below ;)
Dim p As Process
Dim window_name As String
For Each p In Process.GetProcessesByName("outlook")
window_name = p.MainWindowTitle.ToString
Next
AppActivate(window_name)
Thread.Sleep(100)
SendKeys.Send("{Up}")
Me.Activate()
Thanks for clues ;)
Upvotes: 1
Reputation: 1
Within Visual Studio, try "Start without Debugging" in the Debug menu. This should be equivalent to running the executable, but you can then attach the debugger ("Attach to Process" in the debug menu) after it starts and see if that leads to a clue.....
Upvotes: 0