Attatching an XML Expansion Pack to a document programmatically
Avner writes about how to attach a smart document XML Expansion Pack to a document programmatically:
Sub AttachManifest()
Dim Namespace As XMLNamespace
Set Namespace = ActiveDocument.Application.XMLNamespaces.Add(“C:\Projects\SD\my.xsd, “My Schema“, “my“, True)
Namespace.AttachToDocument (ActiveDocument)
ActiveDocument.Application.XMLNamespaces.InstallManifest "C:\Projects\SD\manifest_signed.xml", TrueActiveDocument.SmartDocument.SolutionURL = "C:\Projects\SD\manifest_signed.xml"
ActiveDocument.SmartDocument.SolutionID = "My Schema"End Sub
[This is VBA by the way]
Comments
- Anonymous
January 18, 2005
The comment has been removed - Anonymous
January 18, 2005
as already the expansion pack is provided with the solution id, is it needed to assign the "solutionID" here? - Anonymous
January 18, 2005
The comment has been removed - Anonymous
January 20, 2005
Can we detach xml expansion pack programmatically? Coz u know if make any change in dll or in schema, unless u reattach, u'll not see the change in document action pane. - Anonymous
January 21, 2005
Set the SolutionID and SolutionUrl properties to empty strings to remove the attached XML expansion pack - Anonymous
January 24, 2005
The comment has been removed - Anonymous
January 26, 2005
If i want to refresh the Doc. actions pane after adding some data to database on click of command button in doc. actions pane what shoud i do? Coz i want that once the data saved to database , it should visible to me in the list control in document actions pane immideately. - Anonymous
January 27, 2005
All the info you need is in the Office 2003 reference. The method you need is the RefreshPane method: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbaof11/html/ofmthRefreshPane_HV01022462.asp - Anonymous
January 27, 2005
The comment has been removed - Anonymous
January 28, 2005
The comment has been removed - Anonymous
January 28, 2005
The comment has been removed - Anonymous
January 31, 2005
Can i load some controls to document action pane without asociating them to any tags in the Document? - Anonymous
February 08, 2005
Dillip - You have to either associate the control to a tag, or associate it to the entire document. Word or Excel makes the decision whether or not to call ControlCaptionFromID, not you :^(
HOWEVER, you can always choose to hide a control by returning an empty string for a caption. Thus, if you have a control associated with the entire document, when the user changes context, ControCaptionFromID will be called. This means you can go into the document, figure out where you are and determine on your own if the control should be shown (ie, return a non-zero length caption).
BTW, my favorite way to attach solutions is with an XSLT adding to the custom properties while spitting out WordprocessingML :^) - Anonymous
February 09, 2005
Well i wanted a richer control, so i developed the activex control and loading that.
Now i'm facing 2 problems.
1. After loading activex control in doc pane when i'm closing the document after saving it, it's throwing following error in system error format and trying to recover the document.
"Faulting application winword.exe, version 11.0.6359.0, stamp 40c8b025, faulting module unknown, version 0.0.0.0, stamp 00000000, debug? 0, fault address 0x0722d5aa."
2. I want to distribute this smart document in a sharpoint portal site. AS to get smartdoc CASPOL should be needed to be applied properly, i need to know actual stpes to be followed so that users of the site can open the document without any problem. - Anonymous
August 03, 2005
Hi Mark,
The method 'ActiveDocument.Application.XMLNamespaces.InstallManifest' creates a registry key in Windows registry (HKEY_CURRENT_USERSoftwareMicrosoftOfficeCommonSmart TagActions). This key contains a field called 'Filename' that points to the Path (C:ProjectsSD) for the Smart Document dlls.
My Question is, if I set the SolutionID and SolutionURL properties to empty string ("") and then recall the 'InstallManifest' method with a different Path (C:ProjectsNewSDManifestFile.xml), the registry key is not overwriten. Hence, the next time I set SolutionID to something ("My Schema"), the smart document dlls are not loaded from the correct directory.
To provide more information. If I open up Word 2003 and ADD a new XML Expansion Pack from a different directory, the registry key IS updated and the smart document dlls are loaded from the new directory.
I am trying to achieve this programatically because if the User re-installs my application into a new directory I want the smart document dlls to be read from that directory. In such cases, the SolutionID remains the same and only the SolutionURL changes.
I would very much appreciate if you could spare sometime to give me some tips/help.
Best regards,
Wamiq Ansari
wamiq@msn.com - Anonymous
August 04, 2005
Got it!!
well I think this seems to work for me.
First, I remove the installed manifest from Word 2003 and this is how i'm doin it:
foreach (Microsoft.Office.Interop.Word.XMLNamespace l_templateNamespace in ActiveDocument.Application.XMLNamespaces)
{
if (l_templateNamespace.URI == "urn:schemas-microsoft-com.office11template.WordDocSD")
{
l_templateNamespace.Delete();
}
}
Then I simply re-attach the Smart document solution again, and this is how i do it:
string xmlManifestPath = @"C:ProjectsSDmanifest_signed.xml";
ActiveDocument.Application.XMLNamespaces.InstallManifest(xmlManifestPath, false);
HTH,
Wamiq Ansari
wamiq@msn.com