Miscellaneous Debris

Avner Kashtan's Frustrations and Exultations

A Sincere and Permanent Attachment

Our goal for today is automatically attaching a Smart Document to a document - hopefully from a button or a COM add-in or something.

Well, my pre-2003 Office skills are a bit rusty, so I haven't gotten around to making a COM add-in for this - and I think VSTO deployment these days is still too clunky and awkward to be convenient, but for now, this bit of VBA code will attach our manifest to the active document:

[Note: Some of my actions here might be superfluous. I am not entirely sure as to what is necessary. If you can refine this - please do.]

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", True
    
     ActiveDocument.SmartDocument.SolutionURL = "C:\Projects\SD\manifest_signed.xml"
    ActiveDocument.SmartDocument.SolutionID = "My Schema"
   
End Sub


 

Posted: May 31 2004, 11:20 AM by AvnerK | with 1 comment(s)
Filed under:

Comments

TrackBack said:

Avner writes about how to attach a smart document XML Expansion Pack to a document programmatically:
# January 10, 2005 8:10 PM
Leave a Comment

(required) 

(required) 

(optional)

(required)