A
Anne P.
I am working with Word 2003. I need to select information between two
bookmarks. The problem is this:
I have a two column table. In Row1, Column1 before any text is a bookmark
named CapBegin. The table could only be one row or it could be up to five
rows. If it is only one row, after the last text character in Row1, Column1
is a bookmark named CapEnd. If the table is two rows, the CapBegin bookmark
is at the beginning of the Row1, Column1 cell and the bookmark CapEnd is
after the last text character in Row2, Column1 cell.
I need to capture the text in between these two bookmarks (in column 1 only)
and enclose it in a new bookmark named CaseInfo without any table cell
markers. The reason for this is that I need to later capture the contents
of CaseInfo, copy it, create a new document based on an existing document
and paste it into an existing Table Cell as text, not as a nested table, but
I need to retain the formatting of the text that is being copied. Both
documents (source and destination have styles created with the same names,
but with slightly different formatting).
This is the code that I am currently using. However, using this code, the
text is pasted into the new document using the Normal style. I need the
text to be pasted using the styles that are applied in the original
document.
"Begin Code Block"
*****************************************************************************
Public Sub LitigationBack()
'get the info from the current document
Dim pCell As Word.Cell
Dim myTable As Table
Set myTable = ActiveDocument.Tables(1)
Set pCell = myTable.Cell(1, 1)
Do
If pCell.ColumnIndex = 1 Then
strCaseInfo = strCaseInfo & Left$(pCell.Range.Text,
Len(pCell.Range.Text) - 1) & vbCr
End If
Set pCell = pCell.Next
Loop Until pCell Is Nothing
RetrieveBookmarkInfo "Court", strCourt
RetrieveBookmarkInfo "District", strDistrict
RetrieveBookmarkInfo "IndexNo", strIndexNo
RetrieveBookmarkInfo "cmbAttyForSig", strAttyFor
RetrieveBookmarkInfo "Title", strTitle
RetrieveBookmarkInfo "txtAddress", strAddress
'create the litback and past info
Documents.Add Template:= _
Application.Options.DefaultFilePath(wdWorkgroupTemplatesPath) _
& "\SK Pleadings\Pleading LitBack.doc", NewTemplate:=False,
DocumentType:=0
UpdateBookmark "Court", strCourt
UpdateBookmark "District", strDistrict
UpdateBookmark "Index", strIndexNo
UpdateBookmark "CaseInfo", strCaseInfo
UpdateBookmark "AttyFor", strAttyFor
UpdateBookmark "Title", strTitle
UpdateBookmark "Address", strAddress
End Sub
"End Code Block"
*****************************************************************************
Any thoughts would be greatly appreciated.
Thanks,
Anne
bookmarks. The problem is this:
I have a two column table. In Row1, Column1 before any text is a bookmark
named CapBegin. The table could only be one row or it could be up to five
rows. If it is only one row, after the last text character in Row1, Column1
is a bookmark named CapEnd. If the table is two rows, the CapBegin bookmark
is at the beginning of the Row1, Column1 cell and the bookmark CapEnd is
after the last text character in Row2, Column1 cell.
I need to capture the text in between these two bookmarks (in column 1 only)
and enclose it in a new bookmark named CaseInfo without any table cell
markers. The reason for this is that I need to later capture the contents
of CaseInfo, copy it, create a new document based on an existing document
and paste it into an existing Table Cell as text, not as a nested table, but
I need to retain the formatting of the text that is being copied. Both
documents (source and destination have styles created with the same names,
but with slightly different formatting).
This is the code that I am currently using. However, using this code, the
text is pasted into the new document using the Normal style. I need the
text to be pasted using the styles that are applied in the original
document.
"Begin Code Block"
*****************************************************************************
Public Sub LitigationBack()
'get the info from the current document
Dim pCell As Word.Cell
Dim myTable As Table
Set myTable = ActiveDocument.Tables(1)
Set pCell = myTable.Cell(1, 1)
Do
If pCell.ColumnIndex = 1 Then
strCaseInfo = strCaseInfo & Left$(pCell.Range.Text,
Len(pCell.Range.Text) - 1) & vbCr
End If
Set pCell = pCell.Next
Loop Until pCell Is Nothing
RetrieveBookmarkInfo "Court", strCourt
RetrieveBookmarkInfo "District", strDistrict
RetrieveBookmarkInfo "IndexNo", strIndexNo
RetrieveBookmarkInfo "cmbAttyForSig", strAttyFor
RetrieveBookmarkInfo "Title", strTitle
RetrieveBookmarkInfo "txtAddress", strAddress
'create the litback and past info
Documents.Add Template:= _
Application.Options.DefaultFilePath(wdWorkgroupTemplatesPath) _
& "\SK Pleadings\Pleading LitBack.doc", NewTemplate:=False,
DocumentType:=0
UpdateBookmark "Court", strCourt
UpdateBookmark "District", strDistrict
UpdateBookmark "Index", strIndexNo
UpdateBookmark "CaseInfo", strCaseInfo
UpdateBookmark "AttyFor", strAttyFor
UpdateBookmark "Title", strTitle
UpdateBookmark "Address", strAddress
End Sub
"End Code Block"
*****************************************************************************
Any thoughts would be greatly appreciated.
Thanks,
Anne