Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / September 2005

Tip: Looking for answers? Try searching our database.

reading formfields in a table

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Nick Calladine - 17 Sep 2005 09:52 GMT
Can some one provide me the best syntax or method to read a single formfield
which is in a cell of a table

Each cell of the formfield is either a textinput field or dropdownbox.

I used the following code to step through each cell which i wish to read for
validation purposed

For ColumnNumber = 1 To 5
 'Select Cell
 ActiveDocument.Tables(1).Cell(RowNumber + 1, ColumnNumber).Range.Select
 'Select Data In Cell
 Selection.MoveLeft unit:=wdCharacter, Count:=1

<read / test data here>

Next ColumnNumber

Is this a bad way to do it.. i am better reading the cells data and then
figuring it out if its a form field and then act upon the type.

The formfields are not bookmaked as the user can addiontal rows to the
table.. is just a way of getting input and protecting the form.

Many thanks

Yours stupidly
Greg Maxey - 17 Sep 2005 14:04 GMT
Nick,

To be honest I don't see how you do much of anything with your code.  You
say you "step through each cell."  What is RowNumber?  How does RowNumber 1
become RowNumber 2?

Anyway, if each cell in the table contains either a single text field or
dropdown, then you might try:

Sub ScratchMacro()
Dim oCell As Cell
For Each oCell In ActiveDocument.Tables(1).Range.Cells
 MsgBox oCell.Range.FormFields(1).Result
Next
End Sub

Signature

Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.

> Can some one provide me the best syntax or method to read a single
> formfield which is in a cell of a table
[quoted text clipped - 23 lines]
>
> Yours stupidly
Nick Calladine - 17 Sep 2005 16:10 GMT
Sorry Greg if it wasnt too clear

Still learning vba and get more involved with a simple project which is
getting more complex.

Sorry whats i was trying to do it..

I have a table which has none constant rows
Its has about 14 tables cells per row

I basically want to

read the first five cells of  each row
i then need to get the data from the cell (without the word cell info)
then test if this if it was a null field or where i was expecting to find
data.
if the data is invalid then go to each cell and put "invalid" in to each of
the text formfield enteries

if data is valid then do some calculation and write to other cells

and then go through the to the next row to the end of the first table

hopefully that make it clearer

so i looking to read an text formfield, validate if true do an caculation  ;
if false then write information back in to the text formfield within the
cell

i understand than i need to loop through the table / each valid row and i
know the data lies in the first 5 colums.

what i dont know is how to read the textformfield - validate it and then
write back the formfield not the cell

hope thats makes thing a bit more sensicle..

regards

Nick

> Nick,
>
[quoted text clipped - 39 lines]
>>
>> Yours stupidly
Greg Maxey - 17 Sep 2005 16:24 GMT
Nick,

You are still not very clear.  For example, what does this mean?

<"I have a table which has none constant rows"

and this

> Its has about 14 tables cells per row

Do you mean "nine" rows and 14 cells or columns per row?

Again this is just a simplistic example, but if you want to look at the
result of a single formfield in a table cell, compare it to something and
then change it based on that comparison you could use something like:

Sub ScratchMacro()
Dim oCell As Cell
For Each oCell In ActiveDocument.Tables(1).Range.Cells
 If oCell.Range.FormFields(1).Result <> "Greg" Then
   oCell.Range.FormFields(1).Result = "Greg"
 End If
Next
End Sub
Signature

Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.

> Sorry Greg if it wasnt too clear
>
[quoted text clipped - 4 lines]
>
> I have a table which has none constant rows

> I basically want to
>
[quoted text clipped - 76 lines]
>>>
>>> Yours stupidly
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.