Here are some common scenarios for structured content in Microsoft Word:Ī legal firm needs to create documents that contain legal language that should not be changed by the user.Ī business needs to create a proposal cover page where only the title, author, and date are entered by the user.Ī business needs to create invoices where the customer data is included in the invoice at predefined regions. Structured documents are documents that control where content can appear on a document, what kind of content can appear in the document, and whether that content can be edited. This topic provides information about changes to content controls in Microsoft Word 2013 and the document scenarios that those changes enable. With this ability, you can create conditional lists.Learn how Microsoft Word 2013 content controls enable a larger range of structured document scenarios. The simply list demonstrated above will surely find a purpose, but the real benefit of using an ADODB method to associate a list of Excel data with a content control dropdown list is that the array returned includes all data associated with the list (or record) item. If bReprotect Then ActiveDocument.Protect wdAllowOnlyFormFields, TrueĬonditional Content Control Dropdown List If ActiveDocument.ProtectionType wdNoProtection Then Set oFF = ActiveDocument.FormFields("Formfield_DD_List") arrData(0, lngIndex), arrData(0, lngIndex) 'Assumes the CC has a placeholder "Choose Item" entry with no defined value. Set oCC = ActiveDocument.SelectContentControlsByTitle("CC Dropdown List").Item(1) Change sheet name to suit.ĪrrData = fcnExcelDataToArray(strWorkbook, "Simple List") MsgBox "Cannot find the designated workbook: " & strWorkbook, vbExclamation StrWorkbook = ThisDocument.Path & "\Excel Data Store.xlsx" 'The Excel file defining the simple list. You should notice that the data (the simple list) is defined in an Excel workbook named "Excel Data Store.xlsx" The workbook path and and sheet name "Simple List" are passed as arguments to the function shown above.ĭim oCC As ContentControl, oFF As FormField ORS.Open "SELECT * FROM [" & strRange, oConn, 2, 1įcnExcelDataToArray = oRS.GetRows(lngRows)įor the "Simple List" example, the arguments passed to the function and resulting array returned are shown below. Set oRS = CreateObject("ADODB.Recordset") "Extended Properties=""Excel 12.0 Xml HDR=" & strHeaderYES_NO & """ " OConn.Open ConnectionString:="Provider=.12.0 " & _ Set oConn = CreateObject("ADODB.Connection") If bIsSheet Then strRange = strRange & "$]" Else strRange = strRange & "]" If Not bHeaderRow Then strHeaderYES_NO = "NO" 'Default parameters include "Sheet1" as the named sheet, range of the full named sheet _ Optional bHeaderRow As Boolean = True) As Variant Optional strRange As String = "Sheet1", _ Private Function fcnExcelDataToArray(strWorkbook As String, _ See: Populate Userform ListBox or ComboBox Simple Listįor a demonstration of importing a simple list, I will use data from an Excel Workbook sheet named "Simple List." Representative Excel data and data imported into an associated document content control is shown below: However, these are beyond the scope of this tips page. Useform lists and comboboxes are also available for use by a document developer. To make an ActiveX ComboBox function as a dropdown list, set the MatchRequired property = True and the Style property = frmStyleDropdownListģ. Since an ActiveX Listbox is not presented in a "Dropdown" format, it is mentioned for completeness only.Ģ. With Word, the document designer can employ one or more of several different "list" types which enable the document user to make a single (or in some cases multiple) selection. This tips page was inspired by a frequently viewed post in a popular Word support forum and addresses the question "How to import an Excel list into a Word dropdown list?" See: MSOffice Forums Link
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |