Re: Insert Text after Bookmark by PatOSpark
PatOSpark
Thu Jun 19 03:32:00 PDT 2008
Thanks Doug and Gordon. Not only did you both answer my question, but I
really appreciate your tutoring on what exactly I did wrong, not just for
this instance. Yipee, I'm up and running...
"Gordon Bentley-Mix" wrote:
> Doug's solution is probably best if you don't need the "bmRange" Rangbe
> object you've tried to create somewhere else in your code - and it appears
> that you don't. However, if you do need this Range object elsewhere then you
> need to modify your code as follows:
>
> Sub EmpNme()
> Dim PloyNme As String
> Dim bmRange As Range
>
> Set bmRange = ActiveDocument.Bookmarks("Emp6").Range <--- ***HERE***
> PloyNme = InputBox("Please enter name of Employee",, , 10000, 7000)
> bmRange.InsertAfter (PloyNme)
> Selection.GoTo What:=wdGoToBookmark, Name:="Emp6"
> End Sub
>
> Your code failed because although you declared bmRange as a Range, you
> didn't actually set it to a Range. ;-D
>
> --
> Cheers!
> Gordon
>
> Uninvited email contact will be marked as SPAM and ignored. Please post all
> follow-ups to the newsgroup.
>
>
> "Doug Robbins - Word MVP" wrote:
>
> > Use
> >
> >
> > PloyNme = InputBox("Please enter name of Employee",, , 10000, 7000)
> > ActiveDocument.Bookmarks("Emp6").Range.InsertAfter PloyNme
> >
> >
> > --
> > Hope this helps.
> >
> > Please reply to the newsgroup unless you wish to avail yourself of my
> > services on a paid consulting basis.
> >
> > Doug Robbins - Word MVP
> >
> > "Pat-O-Spark" <PatOSpark@discussions.microsoft.com> wrote in message
> > news:7B4E9294-C122-41E7-80E8-B392751EAD4D@microsoft.com...
> > > Hi,
> > > I'm trying to insert text (usually the same text) at several places in a
> > > document. I've bookmarked these places but can't get the right syntax.
> > > Here's a snippet of the code I've written to try to put the employee's
> > > name
> > > in the middle of a sentence (where the bookmark Emp6 exists):
> > >
> > > Sub EmpNme()
> > > Dim PloyNme As String
> > > Dim bmRange As Range
> > >
> > > Set bmRange = ActiveDocument.Bookmarks("Emp6")
> > > PloyNme = InputBox("Please enter name of Employee",, , 10000, 7000)
> > > bmRange.InsertAfter (PloyNme)
> > > Selection.GoTo What:=wdGoToBookmark, Name:="Emp6"
> > > End Sub
> > >
> > > Thanks in Advance
> >
> >
> >