none
Get list of all open word documents in all word instances when word documents are not visible on Application tab in Task Manager RRS feed

Answers

  • Hi,

    Thank you for your posting.

    According to your description, you want to get all opened word documents using VB.Net.

    I have tried this function and found the same issue as you said.

    The function need to get MainWindowHandle. However, if we open a document by programmatically and set Application.Visible to false, there is no related window for this process, so it cannot be get.

    Office COM doesn’t give similar support for this issue.

    As far as I know, you can use Win32 APIs to archive this goal:

    1. EnumProcesses to get all winword processes.

    2. EnumProcessModules for each winword process.

    3. GetModuleFileNameEx for each module getting from step 2.

    Since you are using vb.net, you can use search pinvoke in internet search engine, which can help you translate win32 API usage to vb.net version.

    The article below for your reference:

    http://www.codeproject.com/Articles/18704/Process-viewer

    In addition, I recommend you repost your question on Windows Desktop SDK forum for further help.

    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Friday, October 4, 2013 9:59 AM
    Moderator

All replies

  • Hi,

    Thank you for your posting.

    According to your description, you want to get all opened word documents using VB.Net.

    I have tried this function and found the same issue as you said.

    The function need to get MainWindowHandle. However, if we open a document by programmatically and set Application.Visible to false, there is no related window for this process, so it cannot be get.

    Office COM doesn’t give similar support for this issue.

    As far as I know, you can use Win32 APIs to archive this goal:

    1. EnumProcesses to get all winword processes.

    2. EnumProcessModules for each winword process.

    3. GetModuleFileNameEx for each module getting from step 2.

    Since you are using vb.net, you can use search pinvoke in internet search engine, which can help you translate win32 API usage to vb.net version.

    The article below for your reference:

    http://www.codeproject.com/Articles/18704/Process-viewer

    In addition, I recommend you repost your question on Windows Desktop SDK forum for further help.

    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Friday, October 4, 2013 9:59 AM
    Moderator
  • Hi George,

    Thanks for the reply. I am currently using VB.NET but if this can be done using C#, that should also work for me. I will repost it to Windows Desktop SDK forum as suggested but could you please let me know if this can be done relatively easily in C# compared to VB.NET and if so, please suggest how I can achieve this.

    Friday, October 4, 2013 1:55 PM
  • Hi,

    >>please let me know if this can be done relatively easily in C# compared to VB.NET<<

    C# and VB.NET are both based on .NET framework, and I don’t think which one will be easier. Thread How does C#.NET compare to VB.NET?   gave us some comparisons about these two languages. And I hope it will help you.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Wednesday, October 9, 2013 5:42 AM
    Moderator
  • System.Diagnostics.Process[] processes = System.Diagnostics.Process.GetProcessesByName("winword");
                    foreach (System.Diagnostics.Process wdProc in processes)
                    {
                        MessageBox.Show("The word document with title: " + wdProc.MainWindowTitle + " is open.");
                    }
    Wednesday, October 9, 2013 7:37 PM
  • Hi George, I tried searching for how to use EnumProcesses and other above mentioned api's in vb.net but didn't find much help. Also the article referenced above is an example in C++. Would you please provide some sample example of how to use above api's in vb.net to achieve what I am trying to get. I would highly appreciate your help. Please help.
    Monday, October 14, 2013 5:50 PM
  • Hi Arvindram,

    Thanks for the suggestion but this doesn't help in my scenario when you have word documents not visible in application tab of Task Manager. When they are not visible in application tab,  Process.MainWindowTitle won't give you anything

    Monday, October 14, 2013 6:05 PM