use Bookmark in publisher 2007

R

Ron Yeh

It is very awkward in Word trying to move texts and pictures. Unless we miss
some functions in Word. We currently looking to move our Ventura publisher
files to MS publisher files. We intend to try publisher application due to
its ease of moving picture and text on a page. However, it is not so easy as
in Word to put SQL database info (stored procedure with parameters) into
"proper spot" on Publisher files. Can you make Bookmark in Publisher 2007 as
good as the bookmark in Word 2000 programmatically ? right now I have to use
code like this:
Dim strName As String, numh As Double, shp1 As Shape
' strName = ActiveDocument.Pages(1).Shapes.Item(2).TextFrame.TextRange.Text

For Each shp1 In ActiveDocument.Pages(1).Shapes
If shp1.Type = pbTable Then
Debug.Print shp1.Table.Columns(1).Cells(1).TextRange.WordsCount
If shp1.Table.Columns(1).Cells(1).TextRange.WordsCount > 1 Then
shp1.Table.Columns(1).Cells(1).TextRange.Words(1).Select
shp1.Table.Columns(1).Cells(1).TextRange.Delete
' shp1.Table.Columns(1).Cells(1).TextRange.Collapse
(pbCollapseEnd)
End If

shp1.Table.Columns(1).Cells(1).TextRange.InsertAfter
("CodeNumaddaaa")

End If
Next

This is not good if there's a change on the table.
 
E

Ed Bennett

Ron said:
Can you make Bookmark in Publisher 2007 as
good as the bookmark in Word 2000 programmatically ? right now I have to use
code like this:

I've not used the bookmark in Word 2000, so am not sure what it is
supposed to accomplish. Could you create a Collection object and add
TextRanges or Cells to it?
 
R

Ron Yeh

thanks for your reply.
Here's what I used to do in Word 2000
Preparation:
In Word 2000: Create a template with bookmarks using fieldname of a
recordset from ACCESS as the bookmark name
In VB6 program:
start the Word 2000 app and open the *.dot file
Get the ACCESS recordset then loop through the fieldname of the recordset
call InsertAtBookmark(wordobj, fieldname, fieldvalue)

Public Function InsertAtBookmark(objWordDoc As Object, strBookmark As
String, strText As String) As Boolean
With objWordDoc.bookmarks
If .exists(strBookmark) Then
.Item(strBookmark).Range.Text = strText
adhInsertAtBookmark = True
End If
End With
End Function

the bookmark of Word 2000 can let me know the exact location on the document
and I don't have to worry about the row number, column number.....

If Publisher 2007 can have the same feature, that will be excellent. Or
There exist a better way that I am not aware of.

Ed's suggestion of creating a collection, adding the cells, text ranges to
the collection does not reduce the trouble of finding the exact row number,
column number, text ranges, ...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top