none
Is there a way to close Options dialog programatically? RRS feed

  • Question

  • Hi,

    I have a need to close Outlook's options dialog (Tools -->Options)  programatically. I do not see any API in the VSTO that would let me get handle on this options dialog.

    Is there a workaround or VSTO extensions that would help me accomplish this task. 

    I'm using VSTO SE for Outlook 2007 Add-ins.

    I would appreciate if you could direct me to the correct resources.

    Thank you,

    Rajat

     

     

    Monday, April 18, 2011 2:04 PM

Answers

  • I think I was unclear in what I posted. When the user clicks on OK the property page will close, as far as I know you cannot force it to close from the code. Sorry if I misled you on that.
     
    If the page is a Windows form or something like that you could try disposing of it, but I don't know if that would leave the hosting dialog open or not.

    --
    Ken Slovak
    MVP - Outlook
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
     
     
    "rbshrestha" <=?utf-8?B?cmJzaHJlc3RoYQ==?=> wrote in message news:b08cc24c-43b0-4cf7-b72c-7d788e54cba7...

    Ken,

    Thanks for your prompt reply. I have a custom property page and it's interesting to know that you can close the dialog using the page. This would be my first preference. If this does not work then the only option would be the hack. But before I go into the hacking part, I would like to test and see if can close dialog using my custom option page. Is there a method that I can call (like Dispose())?

    Thank you,

    Rajat


    Ken Slovak MVP - Outlook
    • Marked as answer by Bruce Song Monday, May 9, 2011 12:45 PM
    Monday, April 18, 2011 4:38 PM

All replies

  • As far as I know there isn't anything exposed to close the Tools, Options dialog. If it's your property page that's being displayed you can close that, which will close the dialog. But if it's one of the built-in tabs or someone else's property page there's no way I know of to close the dialog.
     
    About all I can think of would be a hack if you can find the window using Spy++ if it's exposed. In that case you could find the window using a Win32 API pinvoke of FindWindow() or FindWindowEx(), followed by using PostMesage() to send a WM_CLOSE message to the window. I'm not sure that would work or can be done, however, I've not heard of anyone doing it.

    --
    Ken Slovak
    MVP - Outlook
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
     
     
    "rbshrestha" <=?utf-8?B?cmJzaHJlc3RoYQ==?=> wrote in message news:224d90cf-d64f-42a5-a3c7-9d9ae91eb710...

    Hi,

    I have a need to close Outlook's options dialog (Tools -->Options)  programatically. I do not see any API in the VSTO that would let me get handle on this options dialog.

    Is there a workaround or VSTO extensions that would help me accomplish this task. 

    I'm using VSTO SE for Outlook 2007 Add-ins.

    I would appreciate if you could direct me to the correct resources.

    Thank you,

    Rajat

     

     


    Ken Slovak MVP - Outlook
    Monday, April 18, 2011 3:05 PM
  • Ken,

    Thanks for your prompt reply. I have a custom property page and it's interesting to know that you can close the dialog using the page. This would be my first preference. If this does not work then the only option would be the hack. But before I go into the hacking part, I would like to test and see if can close dialog using my custom option page. Is there a method that I can call (like Dispose())?

    Thank you,

    Rajat

    Monday, April 18, 2011 3:58 PM
  • I think I was unclear in what I posted. When the user clicks on OK the property page will close, as far as I know you cannot force it to close from the code. Sorry if I misled you on that.
     
    If the page is a Windows form or something like that you could try disposing of it, but I don't know if that would leave the hosting dialog open or not.

    --
    Ken Slovak
    MVP - Outlook
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
     
     
    "rbshrestha" <=?utf-8?B?cmJzaHJlc3RoYQ==?=> wrote in message news:b08cc24c-43b0-4cf7-b72c-7d788e54cba7...

    Ken,

    Thanks for your prompt reply. I have a custom property page and it's interesting to know that you can close the dialog using the page. This would be my first preference. If this does not work then the only option would be the hack. But before I go into the hacking part, I would like to test and see if can close dialog using my custom option page. Is there a method that I can call (like Dispose())?

    Thank you,

    Rajat


    Ken Slovak MVP - Outlook
    • Marked as answer by Bruce Song Monday, May 9, 2011 12:45 PM
    Monday, April 18, 2011 4:38 PM