c***@comcast.net
2005-02-05 03:07:52 UTC
I have a template with VBA code that receives text via Applescript from
another application. The text has hypertext markups to denote bold and
italic regions. I want to store a formatted version of the text in a
document field. I have written routines to replace the markup regions
with formatting, but while these are in operation the editing is
visible to the user. There is alot of flickering going on. Is it
possible to apply text formatting properties in the background
somewhere and show the result in a single step?
Here's some sample code:
' Replace the first instance of the target string with the specified
replacement.
' The returned range is the "found" range.
Private Function replace(region As Range, target As String, replacement
As String) As Range
Dim findRange As Range
Set findRange = region.Duplicate
With findRange.Find
.ClearFormatting
.text = target
.replacement.text = replacement
.Forward = True
.Format = False
.MatchCase = True
.MatchWholeWord = False
.MatchWildcards = False
.Wrap = wdFindStop
End With
Set replace = findRange
End Function
-------- Then to use it ----
' Any region surrounded by <i> ... </i> should be set to italics
Private Sub setItalics(region As Range)
Dim foundRange As Range
Dim iRange As Range
Set iRange = region.Duplicate
Do
Set foundRange = replace(region, "<i>", "")
If foundRange.Find.Found Then
iRange.start = foundRange.End
Set foundRange = replace(region, "</i>", "")
If foundRange.Find.Found Then
iRange.End = foundRange.start
iRange.Italic = True
End If
End If
Loop Until Not foundRange.Find.Found
End Sub
---- This all works fine, I'd just like to be able to operate on a
range that is hidden somewhere. Is that possible ?
Thanks in advance.
--- chuck
***@spamless.comcast.net
another application. The text has hypertext markups to denote bold and
italic regions. I want to store a formatted version of the text in a
document field. I have written routines to replace the markup regions
with formatting, but while these are in operation the editing is
visible to the user. There is alot of flickering going on. Is it
possible to apply text formatting properties in the background
somewhere and show the result in a single step?
Here's some sample code:
' Replace the first instance of the target string with the specified
replacement.
' The returned range is the "found" range.
Private Function replace(region As Range, target As String, replacement
As String) As Range
Dim findRange As Range
Set findRange = region.Duplicate
With findRange.Find
.ClearFormatting
.text = target
.replacement.text = replacement
.Forward = True
.Format = False
.MatchCase = True
.MatchWholeWord = False
.MatchWildcards = False
.Wrap = wdFindStop
End With
Set replace = findRange
End Function
-------- Then to use it ----
' Any region surrounded by <i> ... </i> should be set to italics
Private Sub setItalics(region As Range)
Dim foundRange As Range
Dim iRange As Range
Set iRange = region.Duplicate
Do
Set foundRange = replace(region, "<i>", "")
If foundRange.Find.Found Then
iRange.start = foundRange.End
Set foundRange = replace(region, "</i>", "")
If foundRange.Find.Found Then
iRange.End = foundRange.start
iRange.Italic = True
End If
End If
Loop Until Not foundRange.Find.Found
End Sub
---- This all works fine, I'd just like to be able to operate on a
range that is hidden somewhere. Is that possible ?
Thanks in advance.
--- chuck
***@spamless.comcast.net