Home » SQL Server

addin.vsto is not launching after installing Word 2007 Add-in


I have developed an addin for Word 2007. I have followed the walkthroughs

Deploying a Visual Studio Tools for the Office System 3.0 Solution for the 2007 Microsoft Office System Using Windows Installer (Part 1 of 2)

Deploying a Visual Studio Tools for the Office System 3.0 Solution for the 2007 Microsoft Office System Using Windows Installer (Part 2 of 2)

and developed the setup project.After that I installed the add-in on a client machine, everything went well, but after launching the Word application, the wordaddin.vsto application did not launch as said in the example in the second walkthrough for Excel add-in.

So, I have downloaded the VSTO 3.0 Runtime samples from


and created a setup for ExcelAddin given in the Samples.  I installed this ExcelAddin and it installed well and when the Excel application is opened the ExcelAddin.vsto is launched and installed the addin.

Please suggest me where I went wrong.


Thanks in advance,






22 Answers Found


Answer 1

make sure u r client got admin privileage.


Answer 2

Hi tukuna,

Yes, the client has got admin privilege.  The client computer (that I have tested) is another computer other than development computer in our office.

I have tested the Excel Addin setup by building the project given in the vsto  3.0 Runtime samples directory. It is installed successfully. When I opened the Excel 2007 application, the ExcelAddin.vsto file launched automatically and asked for installation.

However, the word  Addin that I developed in the similar way as Excel Addin is installed, but when I open Word 2007 application, the WordAddin.vsto file is not being launched automatically.




Answer 3

Hi Surya,

what is the OS  u r client using,If its Vista,Win7 u need to fallow some steps to overcome the security.

Can you provide the error details.and also make sure value are present in registry as defined in the above documents

LoadBehavior =3




Answer 4

Hi Surya

I'm not sure that you're not mixing up the two types of deployment: .msi vs. ClickOnce. If I'm not mistaken, a *.vsto file is only generated for a ClickOnce type of deployment, and can only work with ClickOnce.

The links to which you point describe how to create a setup (.msi) type of deployment, which is more complex, but also provides more flexibility.

You need to use one, or the other.

If a *.msi type of setup installs correctly, the Add-in should be registered and Word should load it automatically (and transparently) when Word is launched. There should be no need of a *.vsto file.


Answer 5

Hi Cindy,


If *.vsto is not required for deployment, then what should be value for the Registry Entry "Manifest" (I have given the .vsto file's path as value "[TARGETDIR]Word2007AddIn.vsto|vstolocal").

Do we not need to package the *.vsto file in the Setup project?

What should we include in the Security Policy? Currently, I am giving the <RSAKeyValue> found in the *.vsto file?


Thank you,



Answer 6

Hi Surya

My mistake - I misread something in your original message. Please ignore my reply!


Answer 7

But I did not get the solution for the issue. All the files 'WordAddin.dll', 'WordAddin.dll.manifest', ''WordAddin.vsto' are installed in a location and the *.vsto is added in the inclusion list.

The same process is working with ExcelAddin. However, for the word  after launching  Word Application, the Windows Customization Installer is not launching.

Even the Word Addin is not appearing in the list 'Active Application Add-ins' of Word 2007 application.

Can anybody help on this?





Answer 8

What do you see as a LoadBehavior value in HKCU\Software\Microsoft\Office\Excel\Addins\<AddIn Name>

Do you have office 2007 PIA's installed? What about VSTO Runtime 3.0?

Can you please run VSTO Troubleshooter and then check if all the pre-requisites are available on the machine?

 To troubleshoot the issue further can you please set VSTO_SUPPRESSDISPLAYALERTS value to 0. For more details follow MSDN article

Debugging in Application-Level Projects



Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.

Answer 9

Hi Sidharth,


The value of the LoadBehavior is 3 in the registy entry for the addin.

All the prerequisites are correctly installed. If i click on the "addin.vsto"  file manually, the addin  is being installed. But it is not being done programatically as said in this walkthrough .

The same Excel Addin mentioned in the above walkthrough works well and is being installed successfully.

But, the Word Addin I developed with all the similar steps mentioned in the walkthrough, its not being installed. First of all, on opening the Word 2007 application, the dialog 'Microsoft Office Customization Installer' is not being launched automatically as shown in the walkthrough.

I want to know, if any thing more is to be done in the Setup Project for installing  Word Addin.





Answer 10

Did you run VSTO Troubleshooter? What were the results.

Did you add VSTO_SUPPRESSDISPLAYALERTS environment variable?



Answer 11

Yes, I have run VSTO Troubleshooter and please check the status here - Office2007Solution_Prerequisites_Installed .

The LoadBehaviour value is 3. I have added VSTO_SUPPRESSDISPLAYALERTS environment variable and set to 0. But no error message is shown when Word 2007 is opened.





Answer 12

Are you deploying the add-in  to HKCU\Software\ or HKLM\Software\ ??



Answer 13

I am deploying addin toHKCU\Software\

Answer 14

what version of Visual Studio are you using to develop your add-in  and setup project?  as others have asked, are you deploying to HKLM or HKCU?  is the test computer 32-bit or 64-bit?

if the vsto  3.0 MSI deployment sample is working, that computer already has all the prerequisites installed and the VSTO troubleshooter won't really tell you much.

if you are using VS2008 SP1, can you look in the event viewer and see if there are any exception messages logged by the VSTO runtime. 




Answer 15

Hi Mary,

I am using Visual Studio 2008 (Not Service Pack 1) to develop add-in  and setup.

I have deployed to HKCU and not HKLM. The test computer is 32-bit.

All the prerequisites are installed. Even the MSI installer installed the add-in files and registy entries successfully.

The only problem is the Microsoft Office Customization Installer Popup Window (that installs add-in into word) is not launching  automatically after opening word  2007 (as mentioned in the Walkthrough Deploying a Visual Studio Tools for the Office System 3.0 Solution for the 2007 Microsoft Office System Using Windows Installer (Part 1 of 2) ).

Even I have used the use the inclusion list API provided by Visual Studio Tools for Office to trust the add-in mentioned in the walkthrough Deploying a Visual Studio Tools for the Office System 3.0 Solution for the 2007 Microsoft Office System Using Windows Installer (Part 2 of 2)

For testing, I have developed an Excel add-in in the similar mentioned in the above two walkthroughs. It is working fine. But, the Word add-in developed using same method is not being installed.

First of all, I want to understand why the Microsoft Office Customization Installer Popup Window is launching in Excel and not launching for Word automatically. Please confirm this.

Also if you have a sample walkthrough for installing  Word 2007 add-in successfully, please provide.

Thank you,



Answer 16

Hi Surya,

I have created a wordaddin following the exact steps as mentioned ,it works perfectly for me.

u can validate the registry entry as shown below

Registry  path-  HKCU\Software\Microsoft\Office\Word\Addins\MywordAddin

 FriendlyName,Description of type String value MywordAddin
 LoadBehavior of type DWORD value 3
 Manifest of type String value [TARGETDIR]MywordAddin.vsto|vstolocal
Make sure u have included .dll.manifest and .vsto files
Also can u check Event log for more on  error details



Answer 17

Hi Patro,

Does the Microsoft Office Customization Installer popup window is being launched automatically after opening word  application on your computer?

I want to clearly say that all the things registry entries, prerequisites are the add-in  files .dll, .dll.manifest, .vsto are perfectly installed on my computer. Even the registry entry for including the add-in in the inclusion list is perfectly added.

The only problem is the Microsoft Office Customization Installer popup window is not being launched automatically after opening word application. I have to manually select the .vsto file to install the add-in.

But I cannot provide for a client an installation file that he has to install manually.

Thank you,



Answer 18

just by chance

Try to check disabled add-in  in MS Word options

1, Office button

2, Word options

3, Add-Ins

4, in the combobox bellow select "Disabled items" and then the click on the button "Go"

5, check if there is any


Answer 19

The only problem is the Microsoft Office Customization Installer Popup Window (that installs add-in  into word) is not launching  automatically after opening word  2007 (as mentioned in the Walkthrough Deploying a Visual Studio Tools for the Office System 3.0 Solution for the 2007 Microsoft Office System Using Windows Installer (Part 1 of 2) ).


the Microsoft Office Customization Installer dialog box appears to the end user if the certificate used to sign the application and deployment manifests are not already trusted on the end user's computer. the inclusion list APIs grants this pre-trust to the certificate.

so if you are using the inclusion list APIs and the dialog box is still appearing, the inclusion list APIs are not being used correctly. if you are using the inclusion list APIs and the dialog box is NOT appearing, the inclusion list APIs are being used correctly.

First of all, I want to understand why the Microsoft Office Customization Installer Popup Window is launching in Excel and not launching for Word automatically. Please confirm this.

every time you create a new Office solution, such as a different Excel or Word add-in, Visual Studio generates a new temporary certificate (.pfx).  each certificate has a different thumbprint.  if you are using the exact same inclusion list code for both the Excel add-in and Word add-in, you are only pre-trusting one of the certificates and the other one still remains untrusted - which is why you only see the Microsoft Office Customization Installer dialog box once.

if you want the dialog box to appear for both Excel and Word, just remove the InclusionListCustomAction from your setup projects and simplify your deployment.



Answer 20

The only difference between deploying an Excel add-in  and a Word add-in is the registry key that you add (HKCU\Software\Microsoft\Office\Word\Addins\). if you can get your Excel add-in to deploy correctly, repeat the same steps for a Word add-in.



Answer 21

Thank you Mary. I have verified all the project thoroughly each and every step.

I found that I have done a mistake in registry entry that I misspelled the entry 'LoadBehavior' as 'LoadBehaviou r'. Due to this the Word application is unable to load the add-in.

I thank all who answered me. I learnt a lot from all of you.

Thank you,



Answer 22

I see a problem doing things this way (add entries manually into registry). Let's say we create a sample Addin (ISAddin). Inorder to deply to my client system, I prepare a MSI and make the entries in registry


CommandLineSafe - 3

Description - ISAddin

FriendlyName - ISAddin

LoadBehavior - 3

Manifest - C:\Program Files(x86).....\ISAddin.vsto

All goes well and the user can see the ribbon(I created in the VSTO project) and menus in it. But then if there are any calls in my implementation like the following -

 isf = IsolatedStorageFile

, API keeps failing...I am not sure why. Try the same with ClickOnce installation, it works like Gem. Can some tell me if I am missing something.



I have a VSTO 2005 SE program that has been installed successfully on many XP machines. Now I have a new client that has Win 7 (64 bit) and Office 2003. The application isn't even installing properly. Almost all of the files are missing from the program files folder. No manifest is installed... Nothing.

I can't figure out what is wrong with this one. In fact, I don't even know where to begin troubleshooting.....

Any help to point me in the right directly would be fabulous.




Hi everyone,

I have developed a Word 2007 Addin and created a setup to deploy it. It installs without problems in Word 2007. Now I have the requirement to also support Word 2010. I was hoping to be able to use the same setup for Word 2010 too. But this isn't the case. I am getting an error message while installing. The message is "Eine Komponente, die mit word 2007 interagiert, ist nicht vorhanden. Bitte führen sie die Setup.exe aus!". Sorry for the german message. Its because the german OS. It says that "a component, which interacts with word 2007, is not available. Please run setup.exe". But I am running setup.exe (not the msi). :D

So I want to know, if I can use a Word2007 addin in word 2010? I am using Visual studio 2010, but targeting the .net framework 3.5. Are there any requirements (.net Framework 4, Office 2010 PIA's, etc) to be able to develop and publish word 2010 addins? I read that the 2010 PIA's are not ready yet. Is this a problem?


Thanks for help,



I am attempting to open an Excel 2007 file (test1.xlsx) from my Word 2007 addin using OleDb. The code runs fine as long as I have the Excel 2007 application running with "test1.xlsx" open.  But if Excel 2007 is not running, I get an exception "External table is not in the expected format" on the myConn.Open() statement. Does anyone know what the problem is?  Here is the code:

using System;
using System.Windows.Forms;
using System.IO;
using System.Data;
using System.Data.OleDb;

using Microsoft.VisualStudio.Tools.Applications.Runtime;
using Word = Microsoft.Office.Interop.Word;
using Office = Microsoft.Office.Core;

namespace testAddIn
    public partial class ThisAddIn
        private void ThisAddIn_Startup(object sender, System.EventArgs e)
            string filename = @"c:\test1.xlsx";
            if (!File.Exists(filename))
                throw new Exception("File not found");

            string myConnStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + filename + ";" + "Extended Properties=\"Excel 8.0;HDR=YES\"";
            OleDbConnection myConn = new OleDbConnection(myConnStr);
            myConn.Open();  // HERE IS WHERE IT FAILS

        private void ThisAddIn_Shutdown(object sender, System.EventArgs e)



hiiii ....i hav created a customized ribbon for excel 2007 using excel 2007 addin option in visual studio 2010 professional....it s well working in the system where i created the ribbon...next i hav published the project,so tat others can use this...but when i run the setup in other systems it gives me some buld errors..along with it excel sheet is opened...but no customized ribbon there..wat to do now...plz help me

Hi everyone!

I'm currently working on a Outlook 2007 VSTO Addin. It's quite easy to figure out how to create a new contact item.

Code Snippet

private void ThisAddIn_Startup(object sender, System.EventArgs e)     

            outlookApp = new Microsoft.Office.Interop.Outlook.Application();
            Outlook.NameSpace outlookNS = outlookApp.GetNamespace("MAPI");
            outlookNS.Logon(Missing.Value, Missing.Value, true, true);

  Outlook.ContactItem myNewContact = (Outlook.ContactItem)outlookApp.CreateItem(Outlook.OlItemType.olContactItem);

   myNewContact.LastName = lastName;

Fine until here, but what i want to realize, is to connect up to a database and create database contacts into Outlook 2007 Contacts. I'm able to connect to my database, but when i'm trying to create contacts, the process is synchronous, so it blocks Outlook completely until the process finished.

So i created a BackgroundWorker:

Code Snippet

BackgroundWorker bw = new BackgroundWorker();

bw.DoWork += bw_DoWork;
bw.RunWorkerCompleted += bw_RunWorkerCompleted;

And in my bw_DoWork fonction, i'm connecting to my database:

Code Snippet

private void bw_DoWork(object sender, DoWorkEventArgs e)


  MyConnection = new OdbcConnection("Dsn=test;sdsn=test;hst=;prt=2399;uid=Admin");
OdbcCommand cmd = new OdbcCommand(st.ToString(), MyConnection);
OdbcDataReader reader = cmd.ExecuteReader();

//I'm sending the query and reading the response and creating contacts.

 while (reader.Read())
   myNewContact.LastName = lastName;

But BackgroundWorker doesn't acts as i was waiting to do. The process is still syncronous and Outlook gets blocked when i'm creating contacts.

So i've made a little tests with my Backgroundworker:

So then i've just commented Contact creation on my
bw_DoWorkmy code became:

Code Snippet

while (reader.Read())

                            lastName = reader.GetString(0);
                            Console.WriteLine("[Database]: " + lastName);

This code is running on BackgroundWorker, and it doesn't block or freeze Outlook. And it runs really OK. But when i'm inserting back Contact creation and calling Save() method, the problem appears.



I'm working on an application level addin for Excel 2007 that just adds a button to the ribbon that does some formatting on the active sheet.  I've been trying to figure out how to create a setup project for my addin that will work in both Windows XP (SP3) and Windows 7.  I thought I had set it up correctly, and it seemed to install correctly, but when I open Excel, it sets the addin's LoadBehavior value from 3 (as I specified in the setup registry entry) to 0.  If I set it back to 3 in the registry, and then open Excel again, it will get set back to 0 again.  So far I have only been able to test this on WinXP systems, but the same issue happened on both my development system and another one, both running XP SP3.

Here's what I did:

I added a custom setup action project to my solution and used it to implement the CAS policy.  I'm not sure if I did this correctly or not, as the person who tested it on a WinXP machine got a message saying that the permissions for the folder were ordered incorrectly.  I couldn't find much information about that, but they changed the permissions for the folder to Full and never got the message again.  I'll post the code for that part below.

Then I added a setup project, and added the primary outputs from the other projects, the prerequisites (Framework 3.5, VSTO, PIA, Windows Installer 3.1), and the registry entries as follows:

Under the key "User/Machine Hive, Software, Microsoft, Office, Excel, AddIns, ABC.MyAddIn", I added the following keys:

Description: "MyAddIn"

FriendlyName: "MyAddIn"

LoadBehavior: 3

Manifest: "[TARGETDIR]MyAddIn.vsto|vstolocal"

I also added the MyAddIn.dll.manifest and MyAddIn.vsto files as outputs.  Code follows:

Custom Setup Action Code:

Imports System.ComponentModel
Imports System.Configuration.Install
Imports System
Imports System.Collections
Imports System.Collections.Generic
Imports System.Security
Imports System.Security.Policy
Imports System.Reflection
Imports System.Diagnostics.Debug

Public Class CASPolicyInstaller

  Public Sub New()

    'This call is required by the Component Designer.

    'Add initialization code after the call to InitializeComponent

  End Sub

  Public Overrides Sub Install(ByVal stateSaver As System.Collections.IDictionary)
    Dim ent As PolicyLevel
    Dim mach As PolicyLevel
    Dim user As PolicyLevel
    Dim sAssemblyPath As String = Me.Context.Parameters("custassembly")

    Dim policyEnumerator As System.Collections.IEnumerator = SecurityManager.PolicyHierarchy()
    ent = CType(policyEnumerator.Current, Policy.PolicyLevel)
    mach = CType(policyEnumerator.Current, Policy.PolicyLevel)
    user = CType(policyEnumerator.Current, Policy.PolicyLevel)

    Dim fullTrust As PermissionSet = user.GetNamedPermissionSet("FullTrust")
    Dim policy As PolicyStatement = New PolicyStatement(fullTrust, PolicyStatementAttribute.Nothing)
    Dim condition As StrongNameMembershipCondition = CreateStrongNameMembershipCondition()
    Dim group As CodeGroup = New UnionCodeGroup(condition, policy)
    group.Name = "MyAddIn"

  End Sub

  '/// <summary>
  '/// Create a StrongNameMembershipCondition that matches a specific assembly
  '/// </summary>
  '/// <exception cref="ArgumentNullException">
  '/// if <paramref name="assembly"/> is null
  '/// </exception>
  '/// <exception cref="InvalidOperationException">
  '/// if <paramref name="assembly"/> does not represent a strongly named assembly
  '/// </exception>
  '/// <param name="assembly">Assembly that will match the strong name membership condition</param>
  '/// <returns>A membership condition that matches the given assembly</returns>
  Public Shared Function CreateStrongNameMembershipCondition(ByVal assembly As Assembly) As StrongNameMembershipCondition
    If assembly Is Nothing Then
      Throw New ArgumentNullException("assembly")
    End If
    Dim assemblyName As AssemblyName = assembly.GetName()
    System.Diagnostics.Debug.Assert(assemblyName IsNot Nothing, "Could not get assembly name.")

    'get the public key blob
    Dim publicKey As Byte() = assemblyName.GetPublicKey()
    If publicKey Is Nothing Or publicKey.Length = 0 Then
      Throw New InvalidOperationException(String.Format("{0} is not strongly named.", assembly))
    End If
    Dim keyBlob As System.Security.Permissions.StrongNamePublicKeyBlob = New System.Security.Permissions.StrongNamePublicKeyBlob(publicKey)

    'create the membership condition
    Dim mc As System.Security.Policy.StrongNameMembershipCondition = New System.Security.Policy.StrongNameMembershipCondition(keyBlob, assemblyName.Name, assemblyName.Version)
    System.Diagnostics.Debug.Assert(mc.Check(assembly.Evidence), "Did not generate a matching membership condition.")
    Return mc

  End Function

  '/// <summary>
  '/// Create a StrongNameMembershipCondition that matches the calling assembly
  '/// </summary>
  '/// <exception cref="InvalidOperationException">
  '/// if <paramref name="assembly"/> the calling assembly is not strongly named
  '/// </exception>
  '/// <returns>A membership condition that matches the calling</returns>
  Public Shared Function CreateStrongNameMembershipCondition() As StrongNameMembershipCondition
    Return CreateStrongNameMembershipCondition(Assembly.GetCallingAssembly())
  End Function

End Class


I have developed an Outlook 2007 add-in VS 2008. I had to register this in HKLM to work for all users on a multi-user environment/terminal server.

It worked pretty smoothly quite a long time on a couple of terminal servers. But I noticed an abnormal behaviour recently on one of the TS, that is... the add-in works for everyone except for a single person, who is infact the owner of the company!

This person worked with the add-in on the servers for some days and now found that it is disabled for him from the trust center; and was not able to enable it since he was also having limited access to that machine like all other users. But the add-in requires to have administrative priviledge to enable it.

I am not getting any reason behind this situation, but need to provide a quick solution/fix so that it never happens in the future.

Is there anyone who was having this problem and can suggest me something on this?

Thanks in advance...

-Jahedur Rahman



We are having a problem deploying a VSTO 2005 Second Edition Add-In and would appreciate any help with this.

We previously successfully deployed this add-in onto a 32bit Windows terminal service environment. By default VSTO installs on a per-user basis. But we got around this limitation by creating a custom CASPOL script which we ran after installation. This script removes the per user permissions and replaces them with per machine permissions.

I have included an example of this script below.

The client has now moved to a 64bit terminal services environment and our add-in is no longer working. The add-in is available but will not load, so our suspicions are that the problem is with the CASPOL script that it is no longer working.

We have tried editing our script so that it targets the Framework64 folder instead of Framework etc. without success.

Example script

%windir%\Microsoft.NET\Framework\v2.0.50727\caspol.exe -u -q -rg "OurDll.a5376b32-bs02-4f7f-897e-025bd33c0fb8"

%windir%\Microsoft.NET\Framework\v2.0.50727\caspol.exe -m -q -rg "OurDll.a5374b32-bf02-4f7f-897e-025re33c0fb8"

%windir%\Microsoft.NET\Framework\v2.0.50727\caspol.exe -m -q -ag My_Computer_Zone -url "OurUrl\*" Nothing -n " OurDll..a5374b32-bblas-4f7f-897e-025bd33c0fb8" -d "Code Group for Our App"


I'd appreciate whatever help anyone can offer.


Peter Evans


Dear Friends,

I have created a simple word addin and tried to deploy it using windows installer. i have followed the following thread and all the links mentioned in the below thread.


I have run the setup and it has completed successfully but when i open the word document addin doesnt work.

Also registry entries are quite visible.

Please find the below link for downloading the sample addin.



Urgent help will be deeply appreciated



We have a problem with a VSTO-developed COM-Addin for Word 2007, created in Visual Basic with VS2008 SP1, together with a Delphi developed tool, in which RTF-formated text is edited with Word 2007 as editor.

The problem is file-locking, and the strange thing is that it only happens when our COM-Addin is activated.
If we inactivate the COM-Addin, no error and no file-lock occurs in the other tool.

I know there is a lot of info in this question and I have tried make is as readable and understandable as possible.
Even if this is a VSTO-related forum, I thought that the Delphi code could help understand the problem in the VSTO COM-Addin.

First is a description of how the Delphi-developed tool works.
Then is a description on what happens in Words auto-triggered events.
Finally there is a description of the behaviour when the two components interact.


The OLE-container is inherited from a standard Delphi OLE-komponent. It shows rtf formatted text retreived from a database and makes it possible to edit the rtf formatted text using the associated editor for rtf documents, in our case MS Word 2007.
After editing, the rtf formatted text is retrieved from the OLE object and stored into the database via a stream class.

The problem is that we get an error that the stream class cannot open the file because it is used by another process.

When showing the rtf text, the text is retrieved from the database and the following code shows it in the OLE container.

// - We need to save the RTF code in a temporary file

 tmpFilename2 := CreateTempFile; // Local function creating a temporary file with the extension ".DOC"// Use TFileStream instead of TStringList...(works better on large files)// write the rtf-text from database (ATextRtf) to stream.

 stream := TFileStream.Create(tmpFilename2, fmCreate or fmOpenWrite);


 stream.Write(PChar(ATextRtf)^, Length(ATextRtf));




 // Create the OLE-object from the created file.

 fOleContainer.CreateOLEObjFromFile(tmpFilename2, False); 

 // temporary files not needed anymore.



Double clicking the OLE-objects opens the text for editing (in this case in MS Word 2007):


After editing the rtf-text formatted in Word, the text is to be retrieved from the OLE object, the following code is executed:

// Get the RTF text from the current document...// - We need to save the document to a temporary file// Here it is important that the temp. file extension is .doc so// that the OleContainer/Operating system connects it with the right// application installed for handling .rtf files (MS Word), when we// reopen the tmp file in the OleContainer (needed, see below)...// See if a MS Word server is running... if not start a Word process// (to be able to access Application object)if fOleContainer.State <> osRunning then 


  tmpFilename2 := CreateTempFile(); // Local function creating a temporary file with the extension ".DOC"

  wordApp := fOleContainer.OleObject.Application;

  wordApp.Options.BackGroundSave := False;












  // NB!// Seems like (only when executing SaveAs in Word with a DIFFERENT// file-format than native .doc in our case rtf ) that we MUST re-open the saved file// in the OleContainer before we can read the contents of the produced// RTF-file. Otherwise this reading will not work (Word holding a lock// on the file or what?). (The file is used by another process is the message).// If we use SaveAs with the default MS word document format (native// .doc), we can read the produced file even if it is still opened in// the Word-process...// i.e. Start of Workaround to release lock... to be able to read file into stream below

  isModifed := self.Modified;

  fOleContainer.CreateOLEObjFromFile(tmpFilename2, False);

  // Because this one sets modification flag to true unconditionally// we have to reset it.

  self.Modified := isModifed;

  // End of Workaround to release lock... // Read file from disk into memory.// Use TFileStream instead of TStringList...(works better on large files)

  stream := TFileStream.Create(tmpFileName2, fmOpenRead);


  SetLength(Result, stream.Size);

  ptrFileAsString := Pointer(Result);

  //fileSize := Stream.Read(ptrFileAsString^, Stream.Size);

  stream.Read(ptrFileAsString^, stream.Size);




  // Temporary file not needed anymore.


The OLE container is created with these properties:

  Parent := TWinControl(Self);

  Left := 0; // Local to Self's coords, i.e. inner left margin

  Top := 0; // -- "" --, i.e. inner top margin

  Width := 1; // So that user cannot select/edit it in design view

  Height := 1; // -- "" --

  AutoActivate := aaDoubleClick;

  Iconic := False;

  AllowInPlace := False;

  AllowActiveDoc := False;

  AutoVerbMenu := True; //False;

  BorderStyle := bsNone;

  ParentColor := True; 

  SizeMode := smAutoSize;

  ShowHint := True;

  Hint := 'No document loaded';

  OnDblClick := ContainerDblClick;

Here is a description of the Word COM-Addin and how it works.

We have code which execute in common word events for Document_Open, Document_BeforeSave, Document_BeforeClose and WindowSelectionChange.



Below is a description on each of them and what happens together with the Delphi tool.

Here we check if we are opening an OLE-object, with the test to not force the document window to show directly.

Dim appSub AsString = ""TryIf debugMode Then WriteLogg("Start OLE test 1: Application.ActiveDocument.Name", 0, "DocumentOpen", DebugFile)

   appSub = Application.ActiveDocument.Name

   If debugMode Then WriteLogg("End OLE test 1: Application.ActiveDocument.Name = " & appSub, 0, "DocumentOpen", DebugFile)

  Catch ex As Exception

   If debugMode Then WriteLogg("OLE test 1 Catch: Application.ActiveDocument.Name. Error: " & ex.Message, 0, "DocumentOpen", DebugFile)


Only thing here is that we updates TOC:

Dim TOCTable As Word.TableOfContents

  If debugMode Then WriteLogg("Update TOC", 0, "DocumentBeforeSave", DebugFile)

  ForEach TOCTable In Doc.TablesOfContents



  TOCTable = Nothing

Here an Ribbon_Invalidate occurs for the applied Ribbon menu.


Some checks are being made of position within the document if the document is of a supported kind, which does not happen for the Delphi RTF-document.


Behaviour in the interaction between the two components:

Step 1: The form in the Delphi tool is opened by the user.

·      Word and COM-Addin is started.

·      Document_Open is triggered with the tempfile ~6C8.DOC

·      OLE-Test is catching the error end Exit sub is executed so the window is not displayed

Step 2: The user double-clicks the RTF-control

·      The event WindowsSelectionChange is triggered, nothing is done with the document or the application status

Step 3: The user clicks the OLE-created menuitem Close and return to Sicada in the Office menu

·      WindowActivate is triggered which does nothing to this document

·      Document_BeforeClose is triggered (see above)

·      Document_BeforeSave is triggered (see above)

·      COM-Addins UninitHandler is triggered which is a part of Word application ending

Step 4: The user clicks Save in the Delphi tools form

·      COM-Addins InitHandler is triggered which is a part of Word startup

·      Document_BeforeSave is triggered with the document name of the OLE-Object, Document in Sicada (see above)

·      Document_BeforeClose is triggered for the document name of the OLE-object, Document in Sicada (see above)

·      Document_Open is triggered for the tempfile document ~6CF.DOC (see above)

·      OLE-Test is catching the error end Exit sub is executed

Step 5: The Delphi tool receives a file lock error on the file ~6CF.DOC
                   If we check file locks with Process Explorer (SysInternals) we see that winword.exe is
                   holding a lock on the file.

We have tried closing the ~xxx.doc file in the Document_Open event. File lock is still there but the process is non-existent.

Strange thing is that the error in Step 5 only occurs when the COM-Addin is activated.
What is causing the ~xxx.doc tempfile to open in step 4 in the first place?

How can we work around or solve this annoying problem.

Thanks in advance

Best Regards Peter Karlström Midrange AB, Sweden

Hi All,

I have developed and Outlook addin for Office 2003 System and it is working fine with all the clients.

A couple of days back, one of my client who installed the addin for the first time complained that, Outlook is showing 'Your copy of Office is not genuine' after installing the addin. It happened with all the systems in their company in which addin is installed.

We install .NET Framework 2.0, VSTO 2005 SE Runtime and Outlook 2003 PIAs before installing the addin.

I don't think that its a problem with my addin (as it worked fine with all the clients perfectly). Isn't it?

The client is arguing that its a problem with my addin. But, unfortunately I couldn't pin down the cause for this even after exploring their system. 

Could anyone please help me in digging out the issue? I need to answer him asap.

Any help is appreciated. Thanks in advance!


Can we install a VSTO Outlook Addin in a network path/UNC path and still load the addin.


I found out how to turn off ShowSpellingErrors and ShowGrammaticalErrors.  I am hoping there is a way to turn off that lightening bolt that shows up under the first word of sentence that is not capitalized.  It may actually be turn off AutoCorrect that I am looking for.


I successfully build setup for Word 2007 Addin and installed on a test machine. Problem is when i opne Word it didnt show me the addin either not in the Add-Ins available list. Works fine on my dev machine.

Any idea what i am missing!!!   ... Thanks in advance.



I have made a VSTO word addin for Word 2007.The addin performs a particular task.

The code in the addin also requires us to open an existing docucment,export it to xps document and then close the word document without saving any changes .

Th code for these steps is below.


 Microsoft.Office.Interop.Word.Document doc;
            object wordTrue = (object)true;
            object wordFalse = (object)false;
            object missing = System.Reflection.Missing.Value;
            object fileToOpen = //a valid path to a docx file

            doc = Globals.ThisAddIn.Application.Documents.Open(
             ref fileToOpen,
                ref missing, ref wordFalse, ref wordFalse, ref missing,
                ref missing, ref missing, ref missing, ref missing,
                ref missing, ref missing, ref missing, ref missing,
                ref missing, ref missing, ref missing);

                targetDocxDoc + ".xps",
                ref missing);

            object dontSaveChanges = (object)Word.WdSaveOptions.wdDoNotSaveChanges;
            doc.Close(ref dontSaveChanges, ref missing, ref missing);


Even after  using  doc.Close(ref dontSaveChanges, ref missing, ref missing); the word prompts the user to save the document .

Intrestingly this only occurs on some machines .All the machines on which this addin is installed are Windows XP SP3 .MS office2007 SP2.

I am stuck up as I am not able to find any environmental issue in these machine which have the same configuration.

Please suggest a way out

Thanks in advance.


Invoking the following code from a Word 2007 Addin causes an IsolatedStorageScope exception (for each IsolatedStorageScope). But it works when invoked from a command/winform application.
Is this something to do with the security policy? How do we correct it?

  isf = IsolatedStorageFile.GetUserStoreForAssembly();
  TracePlus.Print("Current size for Isolated storage is - {0}.", isf.CurrentSize.ToString());
catch (IsolatedStorageException ex)
  isf = IsolatedStorageFile.GetUserStoreForDomain();
  TracePlus.Print("Current size for Isolated storage is - {0}.", isf.CurrentSize.ToString());
catch (IsolatedStorageException ex)



I am creating templates in CRM and when I click on open in word and it opens, it does not have the CRM Addin in word. I have enabled macros.

Can anyone please help.

Thanks in advance.

I have created a Word add-in which would load data in custom ribbon from external web service. I need to have that add-in in a document so that It can populate the data only on that document. I don't want to have application level add-in because It will try to load data for any other word document user might create. I want to do this as this document would serve as a template for other documents. Is this possible? 

If the above is not possible, how do you actually install the word-2007 add-in.  I see this link. Is this the way one should do it? 

I have a small add-in for Word 2007 that installs and licenses just fine in XP.

The code installs just fine in Vista - I can see the custom ribbon and click the buttons - but the buttons I've created don't work because they are protected. I.e. the licensing isn't allowing the code to run, even though a resident license is installed.

I ran the Microsoft License Administrator and was able to confirm that the resident license is properly installed.

I uninstalled it and tried to enter a permanent license key I created (the RL is just 30 days).

The licensing exe program says it cannot communicate with the SLP servers.

So I think my app isn't running because it is never able to authenticate.

Is there some special workaround for Vista? Is some Vista security feature blocking the app? What gives!!!



I am using VSTO on visual Studio 2010 and creating a Word 2007 add in.

When I add a content control to a document I add xml to a custom xml part, this includes the controls tag as well as other data of my own.

When I delete a control I search the custom xml part and remove the xml for the control that was deleted.

What i have just discovered is that when I move a control on a document VSTO is actually raising the BeforeDelete and the AfterAdd events. This means that my custom xml has been deleted and I know longer have access to it. Is there a way I can find out, in the before delete event if the control is simply being moved about so that I dont delete the custom xml associated with it?

My last resort will be to wait until the document is closing and at that point run through all of the nodes in my custom xml and see if they match a content control then if they dont delete the custom xml node. I would need to delete the code the removes the custom xml from the beforedelete event in order for this to work.

Thanks very much



<< Previous      Next >>

Microsoft   |   Windows   |   Visual Studio   |   Sharepoint   |   Azure