How to modify ole object inside word file

Hello!

Suppose we have a word file with an ole object inside it. It’s neccessary to modify this ole object. It should stay inside the work document at the same place. How can I do it?

Probably even exist several ways how to do it.

Hi,

Thanks for your inquiry.

For example, an embedded Excel file in Word document is represented as a Shape node in Aspose.Words’ DOM; you can loop through Shape nodes collection and get reference to the original object, after modifying the Excel file using Aspose.Cells, you can insert it as a new OLE object using the following way and of-course after that remove the old Shape:

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
Stream memoryStream = File.OpenRead(MyDir + "Book1.xls");
Shape oleObject = builder.InsertOleObject(memoryStream, "Excel.Sheet.8", true, null);
doc.Save(MyDir + @"out.docx");

You can insert new Shape after the old Shape (at same location) using the CompositeNode.InsertAfter method.

Best regards,

Thank you for your answer!

This way is absolutely clear. Instead of excel-file autocad-file.
What type should I use? One of these or some other?

AutoCADLT.Drawing.18
AutoCAD.Drawing.18
AutoCAD.Drawing.19

After adding it in the word-file arise an icon, not small scale picture of autocad scheme.
It’s necessary to have exactly a scaled autocad scheme instead of a little icon.

And it shouldn’t be linked but embedded.

After adding an ole object (autocad-file) ProgId equals “Package”. As I can understand it’s a default type i.e. the added ole object doesn’s identified as an autocad file.
Also after adding I tried to change ProgId to one of the types above in turn, but it didn’t bring any result.

Hi,

Thanks for your inquiry.

ProgID stands for "programmatic identifier. I am afraid, there is no such list. The ProgID is stored in document binary as string. We just extract it from there. But I can provide a list of OLE ProgID found in our test documents:

  • MS_ClipArt_Gallery
  • Equation.3
  • WPGraphic21
  • MIDFile
  • MSGraph.Chart.8
  • PBrush
  • MSPhotoEd.3
  • Excel.Sheet.8
  • Excel.Sheet.12
  • WordPad.Document.1
  • Package
  • Word.Document.8
  • Word.Document.12
  • Visio.Drawing.11

Please attach your expected document here for our reference. We will investigate the structure of your expected document as to how you want your final output be generated like. You can create expected document using Microsoft Word. You can insert AutoCAD file in blank Word document using MS Word.

Best regards,

Hello!

I’ve prepared the required example. It consists of two files. The first one is an AutoCAD file (dwg). The second one is a word file with embedden inside it the object from the AutoCAD file. I’ve used Ctrl+C & Ctrl+V combinations for this purpose, I think it’s quite accessible.

The main goal is to embedd by .Net the object from the AutoCAD file (or AutoCAD file but without linking) to a Word file and achive the result like in the attached Word file.

This task hasn’t lost its importance

Hi,

Thanks for your inquiry. We are working over your query and will get back to you soon.

Best regards,

Hello! If you have any information please let me know.

Hi,

Thanks for your inquiry. We have logged your requirement in our issue tracking system. The ID of this issue is WORDSNET-14862. Our product team will further look into the details of this problem and we will keep you updated on the status of this issue. We apologize for your inconvenience and the delayed response.

Best regards,

Hi,

It is to update you that our product team has managed to output following field code in Word document:

{ EMBED AutoCAD.Drawing.19 }

Please test and tell if the output shown in attached “aw.docx” document is acceptable for you?

Best regards,

Hello!

Thanks for your reply! I’ve tried this example. Unfortunately this isn’t what we need now. In the word-file the embedded autocad file isn’t showed like a small-scale picture (a small-scale view of real picture of autocad file), but it’s shown like a typical picture (general case).

Please look the attached comparison. Here what is now and what we want to see. Is it the same current view on your side?

Hi,

Thanks for your inquiry. In this case, you can first Convert DWG to Image by using Aspose.CAD for .NET and then pass this image to DocumentBuilder.InsertOleObject method. Please check the following article:
Converting CAD Drawings to PDF and Raster Image Formats

Hope, this helps.

Best regards,

Hi,

Regarding WORDSNET-14862, could you please confirm if everything with embedded file (except how it’s shown in MS Word) is working fine on your end? Is it opening correctly when you double-click on it?

Best regards,

The issues you have found earlier (filed as WORDSNET-14862) have been fixed in this Aspose.Words for .NET 18.3 update and this Aspose.Words for Java 18.3 update.