I want to add zip files to my word document with bookmark embedded. I can add .pdf, .doc, .txt or .xls file but i can not add .zip files to my word document. How can i do this? Is it class type problem?
Bookmark bmEmbedded = doc.Bookmarks["ek10"];
bmEmbedded.Select();
object classType = "Word.Document.12";
if (uzanti.Contains(".doc")) classType = "Word.Document.15";
else if (uzanti.Contains(".xls")) classType = "Excel.Sheet";
else if (uzanti.Contains(".txt")) classType = "Text Document";
**else if (uzanti.Contains(".msg")) classType = "Outlook.Item";**
else if (uzanti.Contains(".pdf") || uzanti2.Contains(".pdf")) classType = "AcroRd32.Document";
wordApp.Selection.Range.InlineShapes.AddOLEObject(ClassType: classType, FileName: embeddedFilePath2, DisplayAsIcon: true, LinkToFile: false, IconFileName: labelControl64.Text);
In order to embed a file in a Word document an OLE Server
is required. These are applications that are listed in the Registry as being OLE Servers for a certain file type. Excel, for example, is registered as the OLE Server for xlsx
files.
If there is no available OLE Server Word can embed a file as a generic "Package". Whether this can be successfully "unpacked" at a later time is uncertain, however.
In order to determine the code required for embedding any type of file, the surest way is to record a macro while inserting the file in Word. On my machine, if I embed a zip
file the recorded code is:
Selection.InlineShapes.AddOLEObject ClassType:="CompressedFolder", _
fileName:="C:\Test\CalcIfFields.docx.zip", LinkToFile:=False, _
DisplayAsIcon:=False
Whether this will work in your environment I cannot know...