Add Microsoft Word building block or quick part with Aspose.Words REST API

Hello,

We have existing building blocks in our template that we want to insert at a point in a document. For example we want to replace {{BuildingBlock}} with a building block.

I can see that the Words Aspose product has this option but I can’t find any reference for Building Blocks in the cloud product.

Is this supported? If not, how can we insert complicated text (e.g. text, tables) into the document?

Thanks

@patrick_daly

Thanks for your inquiry. I am afraid Aspose.Words Cloud does not support Building Blocks. You can use following APIs to insert Text and Tables into the Word document. Hopefully it will help you to accomplish the task. However, if it does not fulfill you requirements, then please share some more details along with your sample input document with expected document. We will look into it and will guide you accordingly.

Insert Paragraph
Insert Run
Insert Table

The data we need to insert is not simple text or even tables, it’s a combination of text and tables.

It is basically this document but in word format: https://www.ag.gov.au/Publications/Statutory-declarations/Documents/commonwealth-statutory-declaration-form.pdf

However we have 7 different versions to insert, so thats why I wanted to use Building Blocks.

How else could we achieve this?

Could we have 7 sections already in the document and delete the 6 that we don’t need?

@patrick_daly

Thanks for the additional information. We have logged following tickets in our issue tracking system for further investigation and implementation of your requested features. We will keep you updated about the issues resolution progress within this forum thread.

WORDSCLOUD-917: Support of Building Blocks in Aspose.Words Cloud
WORDSCLOUD-918: Support to delete specific document section

@patrick_daly

In reference to WORDSCLOUD-917, we have started the investigation of the feature. We will appreciate it if you please clarify the following questions, all these answers would help us to make the most convenient API for you.

  1. Do you need to replace a specific text in the document with a building block or is it OK to have an opportunity to add a building block after a specific node (paragraph for example)?
  2. How are your building blocks stored? Are they separated documents or all of them somehow stored in one document (e.g. dotx or dotm)? If so, could you please send the example of such document?
  3. Did you use Aspose.Words for this purpose? If so, it would be great if you could provide an example of code which you used to obtain an appropriate result.

@patrick_daly

We have resolved WORDSCLOUD-918 in latest release, 19.10. From now on sections can be removed in two ways:

  1. Through DELETE Sections API
  2. Through DELETE Range API

The last one is preferred in case if it is required to remove several sections at once.

@tilil.ahmed

  1. Replacing specific text would be better, but after a node could be acceptable
  2. Our building blocks will be stored inside the docx file in the Quick Parts gallery. I have attached a sample. bb quick parts sample.zip (28.4 KB)
  3. No but we have used Visual Basic macros to do this:

Private Sub insertLHNSW()
Dim ccBUs As ContentControls
Dim ccBU As ContentControl
Set ccBUs = ActiveDocument.SelectContentControlsByTag(“BusinessUnit”)
Set ccBU = ccBUs(1)
ccBU.Range.Text = “BC”
ActiveDocument.ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
Selection.Range.Delete
ActiveDocument.AttachedTemplate.BuildingBlockEntries(“Letterhead NSW”).Insert Where:=Selection.Range, RichText:=True
ActiveDocument.ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
Call insertABNG
End Sub

@patrick_daly,

Thank you for your feedback, definitely it will help us to implement the requested feature. We will notify you as soon as we resolve the issue.