Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #3  
Old 08-31-2020, 05:19 AM
spinn2046@gmail.com spinn2046@gmail.com is offline Word form that auto-populates (from Excel sheet) other content controls based on one,manually filled Windows 7 64bit Word form that auto-populates (from Excel sheet) other content controls based on one,manually filled Office 2010
Novice
Word form that auto-populates (from Excel sheet) other content controls based on one,manually filled
 
Join Date: Aug 2020
Posts: 6
spinn2046@gmail.com is on a distinguished road
Default

Hey Greg.
Diving into this code you posted right now.
I'm not expecting you to do anything for me, but I'd appreciate few hints.

This first macro you posted:
Code:
Option Explicit

Private Sub Document_ContentControlOnExit(ByVal oCC As ContentControl, Cancel As Boolean)
Dim arrData() As String
Dim lngIndex As Long
  Select Case oCC.Title
    Case "Name"
      If Not oCC.ShowingPlaceholderText Then
        'Determine which dropdown list entry was selected. Note: The object model has no direct way to do this.
        For lngIndex = 1 To oCC.DropdownListEntries.Count
          If oCC.Range.Text = oCC.DropdownListEntries.Item(lngIndex) Then
            'Get the data from the CC value property.
            arrData = Split(oCC.DropdownListEntries.Item(lngIndex).Value, "|")
            Exit For
          End If
        Next lngIndex
        'Use that date fill in the transposed name and fill the dependent fields.
        With oCC
          .Type = wdContentControlText
          .Range.Text = arrData(0)
          .Type = wdContentControlDropdownList
        End With
        'In the Excel data, "~" is used to define linebreaks in the address column.  Replace with linebreaks.
        ActiveDocument.SelectContentControlsByTitle("Address").Item(1).Range.Text = Replace(arrData(1), "~", Chr(11))
        ActiveDocument.SelectContentControlsByTitle("Phone Number").Item(1).Range.Text = arrData(2)
      Else
        'Reset the dependent CCs.
        ActiveDocument.SelectContentControlsByTitle("Address").Item(1).Range.Text = vbNullString
        ActiveDocument.SelectContentControlsByTitle("Phone Number").Item(1).Range.Text = vbNullString
      End If
    Case Else
  End Select
lbl_Exit:
  Exit Sub
End Sub
What does it actually do??

At the moment I've added main content control (formatted text) (person's registration number) (column "B" in the excel sheet)) to the .docm file and I think the next step is to connect this content control with the column "B" in the excel sheet.
It looks like this now - sorry but my Office 2010 is Polish version.








What is the next step I should do??
Reply With Quote
 

Tags
word fields, word vba, word vba macro



Similar Threads
Thread Thread Starter Forum Replies Last Post
Word form that auto-populates (from Excel sheet) other content controls based on one,manually filled Reset "Button" to clear Word user-filled form, from all filled details. Rafi Word VBA 20 01-20-2023 02:16 PM
Word form that auto-populates (from Excel sheet) other content controls based on one,manually filled VBA to Populate text content controls in word from excel lmoir87 Word VBA 15 05-27-2022 04:22 PM
Auto populate form (data from excel) in Word based on drop down list selection (data from excel) wvlls Word VBA 1 03-22-2019 02:29 PM
Form with content controls - expands but at the bottom of the form louiseword Word 3 05-27-2016 12:47 AM
Word form that auto-populates (from Excel sheet) other content controls based on one,manually filled Date auto-populates based on checkbox mcarter9000 Word VBA 5 12-23-2010 12:39 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:22 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft