V
vjp2.at
I tend to write a lot of documents in text-only format, with
the following conventions:
This_is_italic This*is*bold
[This is a footnote] <This is a chapter heading>
In the case of bold/italic, I'd want any token that has _ or * in it.
Normally, I don't do documents that are so long as to make manual conversion
feasible. A year ago, when I had a non-profitable emergency, Klaus Linke was
so kind as to write me a macro to do the most cumbersom conversion, for
footnotes. The convention I use for bold and italic, I understand is much
more problematic. The chapter headings I would need so I can have a table of
contents. Right now I have no immediate need for this, but I am considering
returning to that non-profitable undertaking.
Incidentally, I used to use SCRIBE where the conventions were
@i(This is italic) @b(This is bold)
@foot(This is a footnote) @chap(This is chapter heading)
@u(This is underline) @sec(This is a chapter heading)
Furthermore, I've programmed in a number of languages (FORTRAN, ALGOL,
PASCAL, C) so I don;t mind doing a little bit of coding so long as I
understood (how to find) all the MS Word variable names.
I'm attaching whatever VB macros I do have, and comments others have
offered. If I seem a bit confused it is from the short attention span I have
been able to afford to direct towards this project.
.Text = "*\_*"
.Text = "*\**"
\*[!^13]@\*
Sub Foot()
Dim myRange As Range
Dim boolFound As Boolean
Dim myFootnote As Footnote
Set myRange = ActiveDocument.Content
Do
myRange.Find.ClearFormatting
With myRange.Find
.Text = "\[*\]"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchWildcards = True
End With
myRange.Find.Execute
boolFound = myRange.Find.Found
If boolFound Then
myRange.Characters.Last.Delete
myRange.Characters.First.Delete
myRange.Cut
Set myFootnote = ActiveDocument.Content.Footnotes.Add( _
Range:=myRange)
myFootnote.Range.PasteAndFormat (wdPasteDefault)
Set myRange = ActiveDocument.Content
myRange.Collapse (wdCollapseStart)
Else
Exit Sub
End If
Loop
End Sub
Sub jb()
'
' Macro written by Maniac on May 16, 2006
' Reformats text between two strings
'
' Specify search phrases (start / end)
A$ = "abc"
B$ = "def"
' Start at the beginning and reset all
' search formatting options
ActiveDocument.Range(0).Select
Selection.Find.ClearFormatting
' Loop repeats until first phrase not found
While Selection.Find.Execute(A$)
StartReformat = Selection.End
Selection.MoveRight
Selection.Find.Execute (B$)
StopReformat = Selection.Start
Selection.MoveRight
' Add formatting to the following section
' Options include:
' .Bold, .Italic, .Underline, .StrikeThrough (true / false)
' .Size = font size
' .Font.Color = wdColorGreen (Red, Blue, etc... see help)
With ActiveDocument.Range(StartReformat, StopReformat)
.Bold = True
.Font.Color = wdColorBlue
End With
Wend
End Sub
- = -
Vasos Panagiotopoulos, Columbia'81+, Reagan, Mozart, Pindus, BioStrategist
http://ourworld.compuserve.com/homepages/vjp2/vasos.htm
---{Nothing herein constitutes advice. Everything fully disclaimed.}---
[Homeland Security means private firearms not lazy obstructive guards]
[Urb sprawl confounds terror] [Remorse begets zeal] [Windows is for Bimbos]
the following conventions:
This_is_italic This*is*bold
[This is a footnote] <This is a chapter heading>
In the case of bold/italic, I'd want any token that has _ or * in it.
Normally, I don't do documents that are so long as to make manual conversion
feasible. A year ago, when I had a non-profitable emergency, Klaus Linke was
so kind as to write me a macro to do the most cumbersom conversion, for
footnotes. The convention I use for bold and italic, I understand is much
more problematic. The chapter headings I would need so I can have a table of
contents. Right now I have no immediate need for this, but I am considering
returning to that non-profitable undertaking.
Incidentally, I used to use SCRIBE where the conventions were
@i(This is italic) @b(This is bold)
@foot(This is a footnote) @chap(This is chapter heading)
@u(This is underline) @sec(This is a chapter heading)
Furthermore, I've programmed in a number of languages (FORTRAN, ALGOL,
PASCAL, C) so I don;t mind doing a little bit of coding so long as I
understood (how to find) all the MS Word variable names.
I'm attaching whatever VB macros I do have, and comments others have
offered. If I seem a bit confused it is from the short attention span I have
been able to afford to direct towards this project.
.Text = "*\_*"
.Text = "*\**"
\*[!^13]@\*
Sub Foot()
Dim myRange As Range
Dim boolFound As Boolean
Dim myFootnote As Footnote
Set myRange = ActiveDocument.Content
Do
myRange.Find.ClearFormatting
With myRange.Find
.Text = "\[*\]"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchWildcards = True
End With
myRange.Find.Execute
boolFound = myRange.Find.Found
If boolFound Then
myRange.Characters.Last.Delete
myRange.Characters.First.Delete
myRange.Cut
Set myFootnote = ActiveDocument.Content.Footnotes.Add( _
Range:=myRange)
myFootnote.Range.PasteAndFormat (wdPasteDefault)
Set myRange = ActiveDocument.Content
myRange.Collapse (wdCollapseStart)
Else
Exit Sub
End If
Loop
End Sub
Sub jb()
'
' Macro written by Maniac on May 16, 2006
' Reformats text between two strings
'
' Specify search phrases (start / end)
A$ = "abc"
B$ = "def"
' Start at the beginning and reset all
' search formatting options
ActiveDocument.Range(0).Select
Selection.Find.ClearFormatting
' Loop repeats until first phrase not found
While Selection.Find.Execute(A$)
StartReformat = Selection.End
Selection.MoveRight
Selection.Find.Execute (B$)
StopReformat = Selection.Start
Selection.MoveRight
' Add formatting to the following section
' Options include:
' .Bold, .Italic, .Underline, .StrikeThrough (true / false)
' .Size = font size
' .Font.Color = wdColorGreen (Red, Blue, etc... see help)
With ActiveDocument.Range(StartReformat, StopReformat)
.Bold = True
.Font.Color = wdColorBlue
End With
Wend
End Sub
- = -
Vasos Panagiotopoulos, Columbia'81+, Reagan, Mozart, Pindus, BioStrategist
http://ourworld.compuserve.com/homepages/vjp2/vasos.htm
---{Nothing herein constitutes advice. Everything fully disclaimed.}---
[Homeland Security means private firearms not lazy obstructive guards]
[Urb sprawl confounds terror] [Remorse begets zeal] [Windows is for Bimbos]