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:ProjectsSDmy.xsd, “My Schema“, “my“, True)
    Namespace.AttachToDocument (ActiveDocument)
    ActiveDocument.Application.XMLNamespaces.InstallManifest “C:ProjectsSDmanifest_signed.xml”, True
    
     ActiveDocument.SmartDocument.SolutionURL = “C:ProjectsSDmanifest_signed.xml”
    ActiveDocument.SmartDocument.SolutionID = “My Schema”
   
End Sub



 

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.