R
RPJ
As a complete VBA novice, I want to overwrite some Bookmarked text with
specific AutoText and retain the Bookmark (so I can repeat this Macro if/when
rqrd).
I have manged so far to generate the following simple code:
Sub CHOOSE_TEXT()
'
' SLT Macro
'
Selection.GoTo What:=wdGoToBookmark, Name:="LTXT"
Selection.Find.ClearFormatting
With Selection.Find
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
With ActiveDocument
If .FormFields("Dropdown1").Result = "Specification No." Then
Application.DisplayAutoCompleteTips = True
NormalTemplate.AutoTextEntries("SLT").Insert Where:=Selection.Range, _
RichText:=True
Else
Application.DisplayAutoCompleteTips = True
NormalTemplate.AutoTextEntries("QLT").Insert Where:=Selection.Range, _
RichText:=True
End If
End With
End Sub
The above Macro is run on exit from a dropdown box in a form within an
earlier protected section of the document.
UNFORTUNATELY if the Bookmark "LTXT" is text then the macro only works once
as it obliterates the Bookmark along with the text.
IF the bookmark "LTXT" is just a position within the document then the macro
will happily re-run - BUT it doesn't replace text (it just pushes it down the
document, which is not acceptable).
CAN ANYONE HELP, PLEASE?
Rgds,
RPJ
specific AutoText and retain the Bookmark (so I can repeat this Macro if/when
rqrd).
I have manged so far to generate the following simple code:
Sub CHOOSE_TEXT()
'
' SLT Macro
'
Selection.GoTo What:=wdGoToBookmark, Name:="LTXT"
Selection.Find.ClearFormatting
With Selection.Find
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
With ActiveDocument
If .FormFields("Dropdown1").Result = "Specification No." Then
Application.DisplayAutoCompleteTips = True
NormalTemplate.AutoTextEntries("SLT").Insert Where:=Selection.Range, _
RichText:=True
Else
Application.DisplayAutoCompleteTips = True
NormalTemplate.AutoTextEntries("QLT").Insert Where:=Selection.Range, _
RichText:=True
End If
End With
End Sub
The above Macro is run on exit from a dropdown box in a form within an
earlier protected section of the document.
UNFORTUNATELY if the Bookmark "LTXT" is text then the macro only works once
as it obliterates the Bookmark along with the text.
IF the bookmark "LTXT" is just a position within the document then the macro
will happily re-run - BUT it doesn't replace text (it just pushes it down the
document, which is not acceptable).
CAN ANYONE HELP, PLEASE?
Rgds,
RPJ