KJQ

Hello all,

I currently have a Word 2003sp2 VSTO solution that dynamically adds a customization which works fine. Now, I am trying the same thing with Excel 2003sp2 and I get the following error:

Microsoft.VisualStudio.Tools.Applications.Runtime.CannotLoadManifestException: Unable to retrieve the manifest from the document.

at Microsoft.Office.Tools.OfficeAppInfoDocument.EnsureDocument()
at Microsoft.Office.Tools.OfficeAppInfoDocument.WriteItem(String element, String id, Byte[] item)
at Microsoft.VisualStudio.Tools.Applications.Runtime.AppInfo.WriteManifest(IAppInfo appInfo, String manifest)
at Microsoft.VisualStudio.Tools.Applications.Runtime.Customizer.CustomizeDocument()
at Microsoft.VisualStudio.Tools.Applications.Runtime.Customizer.Customize()
at Microsoft.VisualStudio.Tools.Applications.Runtime.ServerDocument.AddCustomization(String documentPath, String assemblyName, String deploymentManifestPath, String applicationVersion, Boolean makePathsRelative)

Here is a sample of a quick test case that I am running:

[Test]
public void TestCustomizationForExcel()
{
string path = @"C:\home\MySpreadsheet.template.xls";
string assembly = @"C:\Documents and Settings\kjq\Local Settings\Application Data\test\templates\Office.Excel_1.0.0.0\Office.Excel.dll";
string manifest = @"C:\Documents and Settings\kjq\Local Settings\Application Data\test\templates\Office.Excel_1.0.0.0\Office.Excel.dll.manifest";
string version = "1.0.0.0";

bool isCustomized = ServerDocument.IsCustomized(path);

Console
.WriteLine("IsCustomized: "
+ isCustomized);

ServerDocument.AddCustomization(path,assembly,manifest,version,false);
}

[Test]
public void TestCustomizationForWord()
{
string path = @"C:\home\NewDocument.template.doc";
string assembly = @"C:\Documents and Settings\kjq\Local Settings\Application Data\test\templates\Office.Word_1.0.0.0\Office.Word.dll";
string manifest = @"C:\Documents and Settings\kjq\Local Settings\Application Data\test\templates\Office.Word_1.0.0.0\Office.Word.dll.manifest";
string version = @"1.0.0.0";

bool isCustomized = ServerDocument.IsCustomized(path);

Console.Out.WriteLine("IsCustomized: " + isCustomized);

ServerDocument.AddCustomization(path,assembly,manifest,version,false);
}

If I run the project out of VS2005 the Excel document starts up and shows the customization in the properties but i need to dynamically attach it at runtime. I'm not doing anything currently with the Excel solution but trying to attach the customization so there is no other code involved. This is all running client-side also where I have MS Office and everything else installed (once again this works in Word for me).

Any help would be greatly appreciated.

Thanks.

KJQ




Re: Visual Studio Tools for Office Cannot 'AddCustomization' in Excel (but works fine in Word) using VSTO

KJQ

Ok, so i'm going to respond to my own issue with what seems to fix this problem for me.

1) On the client I was creating and SavingAs a Excel workbook and through the API using the XlFileFormat 'xlXMLSpreadsheet'

2) During my testing I was using this worksheet as the basis for my customization which was giving me the above error (in the original location, different locations, etc).

3) Then I just created a new workbook using Excel on my desktop and pointed my testcase to that and it worked fine.

4) I went back in to the client-factory creating the Excel workbook and changed the SaveAs type to 'xlWorkbookNormal' and restested it and it worked.

KJQ






Re: Visual Studio Tools for Office Cannot 'AddCustomization' in Excel (but works fine in Word) using VSTO

tarunpal

hi,

I am trying to add the customization to an uncustomized excel workbook by using ServerDocument.Add Customization method(..). when I run mu project it gives me access denied eroor at the line where i am wriitng code to add customization by passing the document path,assembly name, manifest name......

I dont know why this error is coming. Any help in this regard..