Word - Stop Loop and Get Value
Asked By Ben
03-Dec-07 02:51 PM
Hi,
I have this loop (see code below) how can I get it to get the value and stop
the loop and move on to the rest of the code which is in the With Doc.
Thank you to anyone that helps,
Happy Holidays.
Ben Z.
With WordDoc
For Each oRow In oTbl.Rows
If oRow.Cells(1).Range.Text = TargetText Then
p = oRow.Cells(1).RowIndex & TextBox1.Text = p
End If
Next oRow
End With
End Sub
Range.Text
(1)
TargetText
(1)
ORow.Cells
(1)
RowIndex
(1)
WordDoc
(1)
ORow
(1)
David Sisson replied...
'Remove the last '=p' it is not needed.
Exit For
Ben replied...
Insert info in header - change date format as you wish oNewDoc.Sections(1).Headers(wdHeaderFooterPrimary).Range.Text = _ 'Adjust the Normal style and Header style With oNewDoc.Styles(wdStyleNormal) With .Font .Name PreferredWidth = 10 'Revision date End With 'Insert table headings With oTable.Rows(1) .Cells(1).Range.Text = "Page" .Cells(2).Range.Text = "Line" .Cells(3).Range.Text = "Type" .Cells(4).Range.Text = "Changed Text Information" .Cells(5).Range.Text = "Author" .Cells(6
to look for specific strings. Each Revision object has a .Range property, and the expression .Range.Text will extract the text of the revision. There is also a .Date property and a Insert info in header - change date format as you wish oNewDoc.Sections(1).Headers(wdHeaderFooterPrimary).Range.Text = _ 'Adjust the Normal style and Header style With oNewDoc.Styles(wdStyleNormal) With .Font .Name PreferredWidth = 10 'Revision date End With 'Insert table headings With oTable.Rows(1) .Cells(1).Range.Text = "Page" .Cells(2).Range.Text = "Line" .Cells(3).Range.Text = "Type" .Cells(4).Range.Text = "What has been inserted or
Etc. 'Or, get header from docSourceData: ' .Cells(1, 2).Value = Left(tblData.Cell(1, 2).Range.Text, _ ' Len(tblData.Cell(1, 2).Range.Text) - 2) ' .Cells(1, 3).Value = Left(tblData.Cell(1, 3).Range.Text, _ ' Len(tblData.Cell(1, 3).Range.Text) - 2) ' .Cells(1, 4).Value = Left(tblData.Cell(1, 4).Range.Text, _ ' Len(tblData
code has no idea where the oBMs are. Use With ActiveDocument TextBox1.Text = .Bookmarks("bkHWS1").Range.Text TextBox2.Text = .Bookmarks("bkHWS2").Range.Text TextBox3.Text = .Bookmarks("bkHWS3").Range.Text TextBox4.Text = .Bookmarks("bkHWS4").Range.Text TextBox5.Text = .Bookmarks("bkHWS5").Range.Text TextBox6.Text = .Bookmarks("bkHWS").Range.Text TextBox7.Text = .Bookmarks
is empty 'Get header from docSourceData: .Cells(1, 2).Value = Left(tblData.Cell(1, 2).Range.Text, _ Len(tblData.Cell(1, 2).Range.Text) - 2) .Cells(1, 3).Value = Left(tblData.Cell(1, 3).Range.Text, _ Len(tblData.Cell(1, 3).Range.Text) - 2) .Cells(1, 4).Value = Left(tblData.Cell(1, 4).Range.Text, _ Len(tblData