-
Thanx!
Thanx! I needed to do it in VBA on document open because its part a document generation application iam writing. I did solve this problem in the end with the following code, but what you suggested does look neater!
[VBA]
Dim sntcount As Integer
Dim sntCounter As Integer
sntCounter = 1
sntcount = ActiveDocument.Sentences.Count
Do While sntCounter <= sntcount
If InStr(ActiveDocument.Sentences(sntCounter), "<<BOLD>>") And _
InStr(ActiveDocument.Sentences(sntCounter), "<</BOLD>>") Then
ActiveDocument.Sentences(sntCounter).Bold = True
ActiveDocument.Sentences(sntCounter) = _
Mid(ActiveDocument.Sentences(sntCounter), Len("<<BOLD>>") + 1, _
Len(ActiveDocument.Sentences(sntCounter)) - (Len("<<BOLD>>") + _
Len("<</BOLD>>")) - 2)
End If
If InStr(ActiveDocument.Sentences(sntCounter), "<<ITALICS>>") And _
InStr(ActiveDocument.Sentences(sntCounter), "<</ITALICS>>") Then
ActiveDocument.Sentences(sntCounter).Italic = True
ActiveDocument.Sentences(sntCounter) = _
Mid(ActiveDocument.Sentences(sntCounter), Len("<<ITALICS>>") + 1, _
Len(ActiveDocument.Sentences(sntCounter)) - _
(Len("<<ITALICS>>") + Len("<</ITALICS>>")) - 2)
End If
If InStr(ActiveDocument.Sentences(sntCounter), "<<UL>>") And _
InStr(ActiveDocument.Sentences(sntCounter), "<</UL>>") Then
ActiveDocument.Sentences(sntCounter).Underline = True
ActiveDocument.Sentences(sntCounter) = _
Mid(ActiveDocument.Sentences(sntCounter), Len("<<UL>>") + 1, _
Len(ActiveDocument.Sentences(sntCounter)) - (Len("<<UL>>") + _
Len("<</UL>>")) - 2)
End If
sntCounter = sntCounter + 1
Loop
[/VBA]
This is obviously quite messy so I will change it now ive had some guidance, but on another issue I also need to do right,left and center justified lines in VBA along the same principle of using tags IE <<L>> <<R>> and <<J>>.
Is it possible to justify text in VBA? thanks again for your help and time
Last edited by geekgirlau; 10-10-2005 at 02:49 AM.
Reason: Put code in VBA tags
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules