Microsoft word add content control
If you have controls in your header/footer, you can add this after the "Next" to loop through headers or footers. I know this is a necromance, but I had the same problem and couldn't find the answer, so I just did it myself and here it is. You can basically adjust everything in this way, just put a watch on ccDefinition and look at what you can adjust while stepping through the code. CodeBank - ASP / ASP.For Each ccDefinition In.Slow Chat with the Microsoft Visual Basic team.Universal Windows Platform and Modern Windows Experience.Quick Navigation Visual Basic 6 and Earlier Top OpenTextFile("C:\temp\TestDocument.hta", 2, 1).Write Join(HtmlArr, vbCrLf)įunction CreateInp(ID, LabelText, EditText, Optional ByVal SpellCheck As Boolean) As Stringįunction CreateBtn(ID, Caption, OnClick) As StringĪrr(3) = " MsgBox ""Content of txt1: "" & document.getElementById(""txt1"").value" They DID assist me in getting this project completed.įlds.Add CreateInp("txt1", "Name (First and Last):", "Enter First and Last Name")įlds.Add CreateInp("txt2", "Street Address/Apt:", "Enter Street Address")įlds.Add CreateInp("txt3", "City:", "Enter City")įlds.Add CreateInp("txt4", "State:", "Enter State")įlds.Add CreateInp("txt5", "Zip:", "Enter ZipCode")įlds.Add CreateInp("txt6", "Phone-Number:", "Enter Phone-Number")įlds.Add CreateBtn("btn1", "Save", "Save()") Thanks to all for your suggestions and help. (Olaf's suggestion made me rethink this as I am used to importing/exporting stuff to excel.)Īnyway.just wanted to let folks know that there are different ways to export data for 'forms' where folks can view and update. This way it also allowed me to easily write the import of that data back into my database. I simply made my Excel export worksheet 'look like' a Word document with Outlines around the cells I want people to review/update. So, if anyone decides to use Word, that is great but I found using Excel much easier (for me). Reading and writing to Excel cells seems even more straightforward than using Fields in a Word document (MY opinion based upon MY experience with both using VB6!!!). I just wanted to update this thread to let all know that, even though Olaf's method is straightforward and is easy to implement, sorta, I elected to use instead Microsoft's Excel for these 'forms' I create. With a few lines of code quite conveniently in VB6, since all the critical input-fields will keep their id-attribute. With its own "WordHTML-gibberish", but it still remains a html-file, which you can open and parse When Word saves such a document back, it will replace the quite sparse (VB-generated) HTML-Content doc suffix only being a hint for either ShellExecute or when the User DoubleClicks the doc) So, Word (at least in the newer versions) is capable to open a plain html-file directly C:\temp\TestDocument.html (in the above right-hand-part of the ScreenShot, opened with IE) C:\temp\ (in the above left part of the ScreenShot, opened with Word) Note, that the above example spits out two (identical) files, which differ only in their ending: OpenTextFile("C:\temp\", 2, 1).Write Join(HtmlArr, vbCrLf)įunction CreateFld(ID, LabelText, EditText, Optional ByVal SpellCheck As Boolean, Optional Style$) As String OpenTextFile("C:\temp\TestDocument.html", 2, 1).Write Join(HtmlArr, vbCrLf) With CreateObject("Scripting.FileSystemObject") 'write two identical files Here is an example of a Word Document with editable Plain Text Content Controls (these are editable fields in the actual Word Doc, and shown in bold red below).Īny suggestions on how to know which Plain Text Content Control is which so I can 'fill' them programmatically, yet keep the controls editable if I send the Document to someone? My goal is to have pre-prepared (data already populated) EDITABLE documents (using the Plain Text Content Controls).įlds.Add CreateFld("txt1", "Name (First and Last):", "Enter First and Last Name")įlds.Add CreateFld("txt2", "Street Address/Apt:", "Enter Street Address")įlds.Add CreateFld("txt3", "City:", "Enter City")įlds.Add CreateFld("txt4", "State:", "Enter State")įlds.Add CreateFld("txt5", "Zip:", "Enter ZipCode")įlds.Add CreateFld("txt6", "Phone-Number:", "Enter Phone-Number")ĭim i: For i = 1 To Flds.Count: HtmlArr(i) = Flds(i): Next What I would LIKE to do is, instead of using 'regular' Word docs, use a template I created to populate the Plain Text Content Controls directly with VB6 code, pulling from data in my Access tables. I also can create (manually) in MS Word (using the Developer Tab) Plain Text Content Controls, which allow someone to take the Word document and click on the control and type in the appropriate information. I also use Access tables from which to pull data and then code in VB6 where those items may go in a Word Document. I know how to create MS Word Documents using VB6.