Consulting

Results 1 to 6 of 6

Thread: Unwanted Outlook Windows

  1. #1
    VBAX Regular
    Joined
    Sep 2005
    Posts
    34
    Location

    Unwanted Outlook Windows

    Hi everyone,

    I've been using a couple of macros to automatically send emails with particular details completed for some time and they have worked fine.

    A few months back after one of the Windows Updates I started to get additional windows opening up in Outlook although I hadn't actually changed the coding. This isn't a big problem when I'm only sending a couple of emails but some some pieces of work the code works through 200 emails and so creates 400 unwanted Windows.

    I use Outlook 2007 with Exchange server.

    I've found that the code which triggers the new windows is:

    [VBA]olApp.GetNamespace("MAPI").Folders.GetFirst.GetExplorer.CommandBars.FindCon trol(, 5613).Execute[/VBA]

    I use it once to set Outlook as offline and later to set Outlook as online. I've found it necessary to include this coding to ensure that Outlook delays doing stuff whilst the code is running. I'd checked out quite a few links from VBA Express to find a way to ensure code had time to run and this worked better for me than the application.wait approach.

    Simplest solution?
    As the windows which open are for folders that are parents of folders that items are being filed into it is possible to predict which windows will appear I suspect that I could add code to close the windows.

    Could you please help with with code for:
    - close a window using a hard coded window name
    - close a window which is the parent of an identifiable folder
    - anything better

    Thanks in advance

    Chris

  2. #2
    VBAX Regular
    Joined
    Sep 2005
    Posts
    34
    Location
    Managed to find
    [VBA]windows.count[/VBA]
    which seems to work for Excel and Word but not in Outlook.

  3. #3
    VBAX Regular
    Joined
    Oct 2011
    Posts
    41
    Location
    I had a similar need to have Outlook wait until a file completely saved before trying to open it and print it. I used this function from Sergey Merzlikin, maybe that will help:

    http://stackoverflow.com/questions/5...n-visual-basic

  4. #4
    VBAX Regular
    Joined
    Oct 2011
    Posts
    41
    Location
    Oh, then basically in my code where I want it to wait, I put this line in with the amount of time I want it to wait in milliseconds:

    [vba]
    'wait for it
    MsgWaitObj 2000
    [/vba]

  5. #5
    VBAX Regular
    Joined
    Sep 2005
    Posts
    34
    Location
    Thanks monarchd. I've found some references to dealing with windows which I'll post about later. I've had a quick look at the link you gave and I see that it is for VB6. Is this directly transferrable to VBA?

    Cheers.

  6. #6
    VBAX Regular
    Joined
    Oct 2011
    Posts
    41
    Location
    By directly transferrable, I think that's a yes. If I recall, I just copied/pasted the code in my Outlook Module and then used it within my existing code. I even call the MsgWaitObj within my loop so that it pauses as it goes thru the attachments on my messages in the Inbox (which it saves the attachment to C:\, waits 2 seconds, opens the file, and then prints it).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •