Hi all,I'm working with parts that will have one or more attachments in the design binder. These will be embedded and not linked. They will be either Excel files or text files. They have been added with the following
myPart.Extension.InsertAttachment(filePath, false);
I'm struggling to find a way to read them with either the OLEObject or GetAttachments approach for a few reason. As they are embedded I cannot use the file path generate by GetAttachments as there is nothing there to open. Equally, for an embedded attachment swOleObj.FileName returns null which means I wouldn't know which attachment is which.
My thought was to use the filepath from GetAttachments to form a search string for SelectByID2. So if I got c:\myfile.txt returned from an entry in the GetAttachments array I would then trim the string for use the in following
if (myPart.Extension.SelectByID2("myfile.txt", "EMBEDLINKDOC", 0, 0, 0, False, 0, Nothing, 0))
{
swOleObj = swSelMgr.GetSelectedObject6(1, 0);
}
This way I would know what OLEObject I have and will be able to use .SetActivate to begin reading it. The trouble is that SelectByID2 returns false. When I used the macro recorded to select myfile.txt in the Design Binder the SelectByID2 line was identical to the line above. Oddly, even replaying the recorded macro wouldn't select myfile.txt.
Can anyone offer any suggestions or tips? I'm open to alternative methods, I just want to read an embedded attachment and know which attachment it is. I've searched the forum and found a similar question that wasn't answered. I've seen a few posts regarding OLEObjects as well but none seem to cover what to do when embedded. I'm working in C# but generally language agnostic.