I have VBA code for Pulling data from Word Forms for Word 2007 & 2010. However, some people that are going to be using the form have older versions of Word. When they open the .docx form, the content controls disappear. I converted the from to use Legacy Controls. I am having a hard time converting the code to get the data from the Legacy Controls. Is there an easy fix for modifying the code?
Thanks
User Profile
Collapse
-
Losing Content Controls when .docx is saved as .doc
-
I have found a solution to my problem. Here is a sample of the code that replaces the default "Click here to enter text", from a plain text content control, with "n/a" in an Access DB:
Code:Case "Agency Name" If cc.ShowingPlaceholderText = False Then agencyName = cc.Range.Text Else: agencyName = "n/a" End If
-
Thank you for your help. I will try to find out where to see if the PlaceholderText Property is set or exists.Leave a comment:
-
The document given to me is a template made by someone else. I'm not sure about the PlaceHolderText Property. The cc is set up in a loop to go through each content control and the controls are plain text:
Code:For Each cc In doc.ContentControls ccInfo = "<> ID= " & cc.ID & " Title = " & cc.Title & " Text = " & cc.Range.Text & vbCrLf Debug.Print
Leave a comment:
-
Here are the ones it doesn't work with. When I use the cc.PlaceholderT ext, I get an error. The error is 91:Object Variable or With Block not Set.
Code:Case "PS Name of School or Program" If cc.Range.Text <> "Click here to enter text" Then psNameOfSchool = cc.Range.Text Else: psNameOfSchool = "n/a" End If
Leave a comment:
-
Changing default text in content control
I am importing data from content controls in Word to Access 2010. When the data is imported, "Click here to enter text" shows up in the DB table. This is when a user leaves that content control empty on the Form. I would like to Have "n/a" show up in the DB table. The code I am using is working for some DB fields but not all. Here is a sample:
Code:Case "CP Goal" If cc.Range.Text <> cc.PlaceholderText
-
I got the checkboxes figured out and here is the finished working code:
Code:Sub GetWordData() Dim cc As ContentControl Dim fc As Field Dim ccInfo As String Dim YourName As String Dim YourAddress As String Dim YourPhone As String Dim Male As String Dim Female As String Dim appWord As Word.Application Dim doc As Word.Document Dim cnn As New ADODB.Connection
Leave a comment:
-
Here is my modified code. Works great. I do have 2 checkboxes that I need if they are checked or not.
Code:Sub GetWordData() Dim cc As ContentControl Dim fc As Field Dim ccInfo As String Dim YourName As String Dim YourAddress As String Dim YourPhone As String Dim Male As CheckBox Dim Female As CheckBox Dim appWord As Word.Application Dim doc As Word.Document
Leave a comment:
-
Thank you for all your help. I am going to have to refer to the title of the content control. This project was given to me by a professor who already has 370+ documents already filled out with this type of controls and need the data imported into Access.Leave a comment:
-
>>>Cut and paste - Start<<<
Start of controls, Count = 5
<> ID= 261426431 Title = YourName Tag = YourName Text = Todd Snavely
<> ID= 846142673 Title = YourAddress Tag = YourAddress Text = 1234 Main St.
<> ID= 2918279744 Title = YourPhone Tag = YourPhone Text = 555-5555
<> ID= 1014266676 Title = Male Tag = Male Text = ?
<> ID= 3052641625...Leave a comment:
-
That did pull the data from the form. Thank you very much. Now, I just got to put that into AccessLeave a comment:
-
I am getting the same error and I am using Access and Word 2010. Also the "classic" field controls.Leave a comment:
-
I commented out line 12 and the error occurs at:
rst.Fields("Ful lName") = doc.FormFields( "YourName").Res ult
I took out the txt in front of YourName so it would match the content control exactly.
Should I change FormFields to ContentControl?Leave a comment:
-
When I get to the line:
rst.Fields("Ful lName")=doc.For mFields("txtYou rName").Result
it sends me to the error handling:
Case -21447022986, 429 section. I kept scrolling through and got error 5941: The requested member of the collection does not exist.
Thank you for your responseLeave a comment:
-
Importing data from Word form content control into Access
I am trying to take the user input from a Word form and place it into an Access DB. I have the document and database in the same folder on my C drive. I am getting an error at :
rst.Fields("Ful lName") = doc.FormFields( "txtYourName"). Result
It is not getting the data from the content control.
Here is all of the of the code:
Code:Sub GetWordData() Dim
No activity results to display
Show More
Leave a comment: