Quantcast
Channel: Microsoft Community - Super Fresh
Viewing all articles
Browse latest Browse all 1237235

VBA to retrieve data from a table cell in Word

$
0
0

Hello,

I am trying to fill in a UserForm with data from the Word document. This data has been merged into the document so it changes. 

Ideally I would like to use VBA programing that retrieves the data from a cell in a table. (I know I could assign a bookmark to each and retrieve it that way, but I am trying to find an easier way because of the number of fields I will be doing this with.)

Right now this is the coding I am using:

Selection.GoTo What:=wdGoToBookmark, Name:="Loc2Data"

With Selection.Tables(1)

    UserForm1.TxtTestloc2.Text = .Cell(2, 2).Range.Text

 End With

The data fills into the text box. The problem is a “paragraph mark” is being put at the end of the data in the text box. When I look at the data in the table and toggle on the paragraph markings, there is not a paragraph mark in that cell.

Any suggestions on how to pull in this data without having a paragraph mark added to the text?

Thank you for your help,

Nancy


Viewing all articles
Browse latest Browse all 1237235

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>