Quantcast
Channel: Open XML Format SDK forum
Viewing all articles
Browse latest Browse all 1288

Is there a way to directly access and modify Content Controls?

$
0
0

hi

I want to access and modify just the parts of the docx document that i setup in developer mode, the goal is to find a statement similar to using select controls by tag?

this is an example of a visual basic or VBA code snippet, Im using c# in asp.net/mvc web app; but the goal is to have a mechanism to accurately and reliably modify the fields of "text content" that i have assigned properties to, the code example is from:

Content Control Grouping & Navigation

the goal is to have a method that i can pass the field name and its new string value to and save the document.  there is a reference document that never changes, its always used as a base document.   

my hopeful method is UpdateField, the unknown Microsoft or openXml method that would define a new control of type text is 

DocumentControlItem(Text)

WordDocumentType mydocument;

public void UpdateField(document, string fieldname, string value){

myTxtcontrol DocumentControlitem  = new DocumentControlItem(Text);
myTxtcontrol = document.SelectContentControlsByTag(fieldname)
}

so is there a way to open the word document and be able to access the fields this way, such as the text controls that were pre defined and saved?

Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean)
  Select Case ContentControl.Tag'"Last" = tag property applied to the last control.
    Case "Last"'"First" = tag property applied to the first control.
       ActiveDocument.SelectContentControlsByTag("First").Item(1).Range.Select
  End Select
lbl_Exit:
  Exit Sub

Viewing all articles
Browse latest Browse all 1288

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>