Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9272417
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T15:52:24+00:00 2026-06-18T15:52:24+00:00

I have looked and failed to find a solution to my problem. I have

  • 0

I have looked and failed to find a solution to my problem. I have developed an Add-in ribbon for Word 2007 which provides an additional set of load and save functions, to allow users to load and save documents from a bespoke system.

I have most of it working – when a user requests a file to be opened, it is downloaded and saved to the AppData folder, and then opened. However, the problem I am having is that if the user for example opens Word and uses this new ‘load’ function, the blank Word document remains, and Word opens the new document quite happily, but it does not get the focus.

(I’m on Windows 7 and it creates a second ‘W’ icon in the task bar for the new document, but it doesn’t switch to it in the same way that Word would if I’d used the normal ‘Open’ route.)

I have tried (as a result of suggestions found elsewhere on here) either setting the ‘visible’ attribute to true, and calling doc.Activate() but neither does what I need. What am I missing? The code I’m using to open the file is below:

private void OK_Click(object sender, EventArgs e)
{
    this.Close();
    FES.FESServices wService = new FES.FESServices();
    int request_id = wService.SubmitRequestFromAddIn(username, password, "RETR", "", textBox1.Text, "", "");
    FES.FileRequestResponse response = wService.GetFileMembersFromAddIn(username, password, request_id);
    if (response.ResponseType == "RETR")
    {
        byte[] data = wService.GetBytesForFilename(response.ResponseValue);
        //MessageBox.Show("Loaded data for file...");
        //MessageBox.Show(Application.UserAppDataPath);
        FileStream fs = new FileStream(Application.UserAppDataPath + "\\" + response.ResponseValue.Substring(6).Split('~')[0], FileMode.Create, FileAccess.Write);
        fs.Write(data, 0, (int)data.Length);
        fs.Close();
        object oMissing = System.Reflection.Missing.Value;

        Microsoft.Office.Interop.Word.Document doc = Globals.ThisAddIn.Application.Documents.Open(
            Application.UserAppDataPath + "\\" + response.ResponseValue.Substring(6).Split('~')[0], Visible:true
        );
        doc.Activate();
    }
}

(I have included this.Close() as the function loading the document is held within a modal dialog box, and without closing it first, Word throws an exception about switching documents with a dialog box open).

Any help gratefully received!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T15:52:26+00:00Added an answer on June 18, 2026 at 3:52 pm

    Running this code whilst the modal dialog is showing is interfering with window activation.

    I’m not sure exactly what the mechanism is for this interference, but the fix is simple enough. Move the code outside the dialog. Execute this code immediately after the call to ShowDialog returns.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have looked all over the internet to find an answer to my problem
So, I have looked everywhere for a solution to this problem I have and
I have looked on the web to find a list of all Python keywords
I have looked thoroughly, but I have not found the solution (or perhaps I
I looked everywhere I can find but can't seem to find a solution to
I've looked everywhere for a technique, but I failed to find much that suited
I have code which downloads a picture from a fake link. I have looked
I have looked all over and can't seem to find an answer. I have
I've looked around StackOverflow and with Google and was unable to find a solution
I have a solution which consists, to put it simply, a Windows Forms Application

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.