If I create an Outlook 2010 object In Excel VBA using
Sub CreateOL() On Error Resume Next Set myOlApp = GetObject(, "Outlook.Application") If Err.Number = 429 Then Set myOlApp = CreateObject("Outlook.Application") End If On Error GoTo 0 End Sub
Is it possible to force
myOLAPP to send/receive. Please can somebody advise how it’s done?
I’ve tried the following but it’s not working for me.
Set nsp = myOlApp.GetNamespace("MAPI") Set sycs = nsp.SyncObjects For i = 1 To sycs.Count Set syc = sycs.Item(i) syc.Start Next
Also, how do I make myOlApp visible?
myOlApp.Visible = True and
myOlApp.Application.Visible = True doesn’t work
Which Outlook version are you using? I tested this with Outlook 2010 and it works.
NOTE: I have not done any error handling. I am sure you can take care of that.
Public Sub Sample() Dim oLook As Object Dim nsp As Object, objSyncs As Object, objSync As Object Dim i As Long Set oLook = GetObject(, "Outlook.Application") Set nsp = oLook.GetNamespace("MAPI") Set objSyncs = nsp.SyncObjects For i = 1 To objSyncs.Count Set objSync = objSyncs.Item(i) objSync.Start Next End Sub
MS Outlook has 2 types of windows
- Explorer for Folders and
- Inspector for individual items.
If you want to show a particular folder, you can start the Explorer for it then either use
.Display. An alternative would be to use
MAPIFolder.Display method as well.