Wordrange with text boxes (1 Viewer)

wackywoo105

Registered User.
Local time
Today, 05:35
Joined
Mar 14, 2014
Messages
203
I've been using the following to add info to a word document from access:

Code:
Set WordRange = oDoc.GoTo(What:=wdGoToBookmark, Name:="Start")
WordRange.InsertAfter Title & " " & [Surname]

The problem is for formatting purposes I would like to use some text boxes. I can add bookmarks to the text boxes. Access however cannot find them and throws an error.

Is there a way to use wordrange with bookmarks in text boxes?
 

Gasman

Enthusiastic Amateur
Local time
Today, 13:35
Joined
Sep 21, 2011
Messages
14,234
Not played around too much with Word VBA up until now.

However I think you would need to address the textboxes directly?
So assign your values to the textbox and format as required.

The difficulty I see, is identifying which textbox is which.? They are named "Text Box 1", "Text Box 2" etc in order of creation.?

Might be safer to name them yourself after creation.?

This link will show you how that might be carried out.

http://www.vbforums.com/showthread.php?486454-RESOLVED-Change-the-name-of-a-textbox-in-a-word-document

Please report back how you get on.

HTH
 

wackywoo105

Registered User.
Local time
Today, 05:35
Joined
Mar 14, 2014
Messages
203
Thanks. I had started to look at shapes as I use that for publisher.
The following code names all the text boxes, so now I should be able to reference them properly.

Code:
Dim t As Word.Shape
For Each t In oDoc.Shapes
    t.TextFrame.TextRange.Text = t.Name
Next

I have this method can be a pain as if you ever edit the document the shape names can alter.
 

Gasman

Enthusiastic Amateur
Local time
Today, 13:35
Joined
Sep 21, 2011
Messages
14,234
Well it is easy enough to rename them in order again, but I agree, it could be a pain.
 

Users who are viewing this thread

Top Bottom