PC Review


Reply
Thread Tools Rate Thread

how to convert selection (not whole document) to BBCode?

 
 
Fai Vapiwalla
Guest
Posts: n/a
 
      14th Jan 2011
Hi All,

I've come across the "The Word2BBCode-Converter ... written on June 2,
2006 by Matthew Kruer" VBA script which works amazingly. I've read
other posts that say it has some issues with coloured text but since I
only use it for converting Bold, Underline, and Italics to BBcode it
is fine.

What I can't figure out is how to modify that code to only convert a
selection to bbcode, and not the whole document. I just want to be
able to (hastily) select a paragraph of text that i can see has some
bolding in it, hit a hotkey combination (that has the word to bbcode
macro attached to it) and have the bolding turned into bbcode. What
part of the below code should I modify, and to what?

The first part of Kruer's code (that deals with converting all
document bolding to bbcode) looks like this:

'Word2BBCode-Converter v0.1

Sub Word2BBCode()

Application.ScreenUpdating = False

ConvertItalic
ConvertBold
ConvertUnderline
ConvertHyperlinks

ActiveDocument.Content.Copy

Application.ScreenUpdating = True
End Sub
Private Sub ConvertBold()
ActiveDocument.Select

With Selection.Find

.ClearFormatting
.Font.Bold = True
.Text = ""

.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False

.Forward = True
.Wrap = wdFindContinue

Do While .Execute
With Selection
If InStr(1, .Text, vbCr) Then
' Just process the chunk before any newline
characters
' We'll pick-up the rest with the next search
.Font.Bold = False
.Collapse
.MoveEndUntil vbCr
End If

' Don't bother to markup newline characters
(prevents a loop, as well)
If Not .Text = vbCr Then
.InsertBefore ""
.InsertAfter "
"
End If

.Font.Bold = False
End With
Loop
End With
End Sub
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I convert a mail merge document to a standard document? Bobthebuilder0418 Microsoft Word Document Management 2 7th Oct 2009 05:21 AM
BBCode Editor for ASP.NET Toni Microsoft ASP .NET 1 27th Sep 2007 03:24 PM
how can i convert a scanned image document to word document =?Utf-8?B?YW5rdXIgc2hhcm1h?= Microsoft Word Document Management 4 25th Feb 2007 02:42 PM
IE add on similar to Firefox's BBCode extension scupper Windows XP Internet Explorer 0 24th Apr 2005 07:08 AM
IE add on similar to Firefox's BBCode extension =?Utf-8?B?RG9u?= Windows XP Internet Explorer 0 24th Apr 2005 03:52 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:14 AM.