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 / November 2006

Tip: Looking for answers? Try searching our database.

Word VBA: Can I order bookmarks on Ms. Word

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
rachitm@gmail.com - 14 Nov 2006 15:04 GMT
I have an insert button on my page, which inserts a row in a table with

6 columns (and 6 formfields) everytime I press it. What I want to know
is
that everytime I insert a row, is there a way I could make sure that
the formfields have ordered bookmarks?

In the 6th column formfield I need to do a calculation which depends on

the 4th column formfield. Is there a way I could do that too (with the
insert row method) ?

Thanks
Greg Maxey - 14 Nov 2006 16:17 GMT
Provided that the selection is in that added row following the
insertion, you may be able to adapt something like this:

Sub ScratchMacro()
Dim oRng As Word.Range
Dim oFrmFlds As FormFields
Dim pRowNum As Long
Dim pIndex As Long
Set oRng = Selection.Rows(1).Range
Set oFrmFlds = oRng.FormFields
pRowNum = oRng.Information(wdEndOfRangeRowNumber)
pIndex = 0
On Error Resume Next
ActiveDocument.Unprotect
On Error GoTo 0
For pIndex = 1 To oFrmFlds.Count 'Should be 6 in your case
 oFrmFlds(pIndex).Select
 Select Case oFrmFlds(pIndex).Type
   Case wdFieldFormTextInput
     With Dialogs(wdDialogFormFieldOptions)
       .Name = "TextRow" & pRowNum & "_" & pIndex
       .Execute
     End With
     If pIndex = 6 Then
       oFrmFlds(pIndex).TextInput.EditType wdCalculationText,
"=TextRow" & pRowNum & "_4 + 10" 'value of the newly bookmarked current
row cell 4 + 10
     End If
   Case wdFieldFormCheckBox
     'Do Nothing
   Case wdFieldFormDropDown
     'Do Nothing
   Case Else
     'Do Nothing
 End Select
Next pIndex
ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True
End Sub

> I have an insert button on my page, which inserts a row in a table with
>
[quoted text clipped - 9 lines]
>
> Thanks
rachitm@gmail.com - 21 Nov 2006 17:03 GMT
Thank you for your help!!

> Provided that the selection is in that added row following the
> insertion, you may be able to adapt something like this:
[quoted text clipped - 48 lines]
> >
> > Thanks
 
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.