RMac,
I was trying to show you that there is no need to "GoTo" anywhere. You can
achieve your objective by leaving the selection alone by using the range
object. TestBM1 and TestBM2 are located in textboxes:
Sub Macro3()
Dim sBoxVal As String, sMark As String
sBoxVal = "SomeDrugName"
sMark = "TestBM1"
Call FillMark(sMark, sBoxVal)
End Sub
Sub FillMark(sMark As String, sBoxVal As String)
Dim oRng As Range
Set oRng = ActiveDocument.Bookmarks(sMark).Range
oRng.Text = sBoxVal
ActiveDocument.Bookmarks.Add sMark, oRng
End Sub
Sub Macro2()
Dim oRng As Range
Set oRng = ActiveDocument.Bookmarks("TestBM2").Range
ActiveDocument.InlineShapes.AddPicture "C:\Pic.bmp", False, True, oRng
End Sub
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~
Greg Maxey - Word MVP
My web site http://gregmaxey.mvps.org
Word MVP web site http://word.mvps.org
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
RMac wrote:
> I thought the same thing. I sense the vibe of a former Wordperfect
> user. However, the advance feature in Word 2000 seems only to provide
> the ability to advance relative to the current position. WP provided
> the capability to advance to a specific position on the page--a much
> more rigorous solution that Word apparently did not see fit to
> include.
>
> For better or worse, a text box appears to be the best way to lock
> something in a specific place on the page. My problem was that the
> selection.goto method of going to a bookmark couldn't find a bookmark
> in a text box unless the bookmark had focus in the document.
> Actually, I found the solution to this question in a posted response
> by Greg Maxey to another question. The trick is to figure out what
> Word is calling the text box in question; then rename it something
> memorable and finally use code to set the focus on the desired
> textbox containing the bookmark of interest before trying to place
> the inline graphic or text where you want it.
>
> The following code is adapted from Greg's post:
>
> Go to page view of the document and click on the box you're
> interested in and then run the following macro. A message box will
> pop up with Word's ID number for the text box: eg. TextBox(20). If
> you run the macro again the new name will show up in the Message Box.
>
> Sub ShapeID()
>
> MsgBox Selection.ShapeRange.Name
> 'Or give it your own name
> Selection.ShapeRange.Name = "WhateverYouWant"
>
> End Sub
>
> Finally I put the following line of code immediately before the
> selection.goto statement for the bookmark inside the TextBox where I
> want to insert text (or inline graphic):
>
> 'Set the focus on the "WhateverYouWant" textbox
> ActiveDocument.Shapes("WhateverYouWant").Select
>
> This seems to work reliably as far as I can tell, however I am
> intrigued by this stuff on "Ranges" Greg was referring to in his post
> to me. I see that a post I tried to make in response to him somehow
> got lost. I will repost.
>
> Anyway, thanks for your response, "sparklynic".
>
> "sparklynic" wrote:
>
>> In the past I have used "advance" to exactly position text on a page
>> when I needed to fill forms in. Perhaps this could be used instead
>> of text boxes. Just a suggestion.
>>
>> Sparklynic
>> ___________________________
>>
>> RMac wrote:
>>> Using Word 2000.
>>>
>>> I am building a document that I want to use to generate written
>>> prescriptions for medicines. In order to control the exact
>>> placement of some text and graphics on the page, I would like to
>>> use textboxes. However, when I use the following code to do the
>>> insertion, the code can't find the bookmarks that are inside a
>>> textbox.