c# - Word Interop- Add new autotext/building block -


i need update bunch of values stored in multiple word documents auto text (or building blocks), there many hand hoping use interop word api.

var app = new application(); var doc = app.documents.open(@"c:\path\to\file.dot"); 

unfortunately cannot see members of document related auto text feature in word (insert > quick parts > building blocks organizer).

does api expose way of adding/updating auto text values in 'building blocks organizer'?

what need create new document , attach template document, top of head:

activedocument.attachedtemplate = @"c:\path\to\file.dot";

after can interate on autotextentries (a vba example, i'm sure can rewrite c# yourself)

sub test()      activedocument.attachedtemplate = @"c:\path\to\file.dot"      each oautotext in activedocument.attachedtemplate.autotextentries         msgbox oautotext.value         oautotext.value = replace(oautotext.value, strold, strnew)     next oautotext  end sub 

Comments

Popular posts from this blog

java - Jasper subreport showing only one entry from the JSON data source when embedded in the Title band -

serialization - Convert Any type in scala to Array[Byte] and back -

SonarQube Plugin for Jenkins does not find SonarQube Scanner executable -