Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 03-31-2018, 02:33 PM
matelot2 matelot2 is offline can I get bbcodes to format in a page? Windows 7 64bit can I get bbcodes to format in a page? Office 2003
Novice
can I get bbcodes to format in a page?
 
Join Date: Jul 2017
Posts: 13
matelot2 is on a distinguished road
Default can I get bbcodes to format in a page?

I am still running 2003 but am trying to make a record of my threads using bbcodes
is there any way of typing the codes like this

HTML Code:
[b][color=blue]Disk Cleanup[/color][/b]

Click [b]Start[/b] and then click [b]Run...[/b].
In word and getting it to show like this?



Disk Cleanup

Click Start and then click Run....

Thanks.

Last edited by matelot2; 03-31-2018 at 02:34 PM. Reason: alter title
Reply With Quote
  #2  
Old 03-31-2018, 09:12 PM
Guessed's Avatar
Guessed Guessed is offline can I get bbcodes to format in a page? Windows 10 can I get bbcodes to format in a page? Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,163
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

Not unless you run a macro to convert the tags to formatting for you.
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #3  
Old 04-01-2018, 10:07 AM
Charles Kenyon Charles Kenyon is offline can I get bbcodes to format in a page? Windows 10 can I get bbcodes to format in a page? Office 2013
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,470
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

This likely could be done with a wild card replace, but I am a novice with that feature.
Replace using wildcards
Using wildcards
Wildcard Cookbook for Microsoft Word by Jack Lyon
Reply With Quote
  #4  
Old 04-01-2018, 11:45 AM
matelot2 matelot2 is offline can I get bbcodes to format in a page? Windows 7 64bit can I get bbcodes to format in a page? Office 2003
Novice
can I get bbcodes to format in a page?
 
Join Date: Jul 2017
Posts: 13
matelot2 is on a distinguished road
Default

Thank you Andrew. I don't know enough about macro's to write one.

Charles, I clicked on your 'wildcards' link and was unaware there were so many 'wildcards' I will certainly keep that in mind.
I don't think it will help here but I will use it on the file I am writing.
Reply With Quote
  #5  
Old 04-01-2018, 01:53 PM
macropod's Avatar
macropod macropod is offline can I get bbcodes to format in a page? Windows 7 64bit can I get bbcodes to format in a page? Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,374
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

A wildcard Find/Replace macro to do the conversion might be coded along the lines of:
Code:
Sub DemoI()
Application.ScreenUpdating = False
With ActiveDocument.Range
  With .Find
    .ClearFormatting
    .Replacement.Text = "\1"
    .Format = False
    .Forward = True
    .Wrap = wdFindContinue
    .MatchWildcards = True
    .Replacement.ClearFormatting
    .Text = "\[b\](*)\[/b\]"
    .Replacement.Font.Bold = True
    .Execute Replace:=wdReplaceAll
    .Replacement.ClearFormatting
    .Text = "\[i\](*)\[/i\]"
    .Replacement.Font.Italic = True
    .Execute Replace:=wdReplaceAll
    .Replacement.ClearFormatting
    .Text = "\[u\](*)\[/u\]"
    .Replacement.Font.Underline = True
    .Execute Replace:=wdReplaceAll
    .Replacement.ClearFormatting
    .Text = "\[color=blue\](*)\[/color\]"
    .Replacement.Font.ColorIndex = wdBlue
    .Execute Replace:=wdReplaceAll
    .Text = "\[color=red\](*)\[/color\]"
    .Replacement.Font.ColorIndex = wdRed
    .Execute Replace:=wdReplaceAll
    .Text = "\[color=green\](*)\[/color\]"
    .Replacement.Font.ColorIndex = wdGreen
    .Execute Replace:=wdReplaceAll
  End With
End With
Application.ScreenUpdating = True
End Sub
The above macro handles bold, italics, underline, plus red, green & blue text. You could extend it to handle more formats.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #6  
Old 04-01-2018, 02:17 PM
matelot2 matelot2 is offline can I get bbcodes to format in a page? Windows 7 64bit can I get bbcodes to format in a page? Office 2003
Novice
can I get bbcodes to format in a page?
 
Join Date: Jul 2017
Posts: 13
matelot2 is on a distinguished road
Default

Macropod, thank you so much.
I have been a little while getting back to you as I have absolutely no idea how to implement macros. However, with a little experimentation I have got it to work.
All my colours are in the format of six figure numbers, the green I have called for is 0040FF so I changed the part of your green line
.Text = "\[color=green\](*)\[/color\]"
to
.Text = "\[color=00400FF\](*)\[/color\]"
and got green writing in bold.
Perfect.
I can now go through and change all the other colours I am using and other formats hopefully and get it all to work.
Thank you for that.
Bob.
Reply With Quote
  #7  
Old 04-01-2018, 03:38 PM
matelot2 matelot2 is offline can I get bbcodes to format in a page? Windows 7 64bit can I get bbcodes to format in a page? Office 2003
Novice
can I get bbcodes to format in a page?
 
Join Date: Jul 2017
Posts: 13
matelot2 is on a distinguished road
Default

Can I ask one more question?
I am trying to find a way of doing it so I can put the original page on and then follow it with the reformatted page.
Is there a way of localising what I change i.e. to a paragraph or highlighted section?
That would then allow me to show both forms.
Looking at it I assume changing 'wdReplaceAll' to something like 'wdReplaceHighlighted' or 'wdReplaceParagraph' might do it but I can't find a list of options?
Might I add something to the '.Execute Replace:=' like 'highlighted=true' or 'paragraph = true'?
I can't see the format?
Is there a reference somewhere that will tell me what I would need to put after '.replacement' to get me things like bullets,numbering etc such as the '.Replacement.Font.ColorIndex? ' you have used.
thanks.
Bob.
Reply With Quote
  #8  
Old 04-01-2018, 03:54 PM
macropod's Avatar
macropod macropod is offline can I get bbcodes to format in a page? Windows 7 64bit can I get bbcodes to format in a page? Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,374
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

If you want two versions, I'd suggest having them in separate documents. That way there's no risk of reformatting the wrong content. Alternatively, you could change:
ActiveDocument
to:
Selection
and change:
wdFindContinue
to:
wdFindStop
then make sure you select the correct one to process...

If you post some content relating to "things like bullets,numbering etc", I'll see what I can come up with.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #9  
Old 04-01-2018, 04:04 PM
macropod's Avatar
macropod macropod is offline can I get bbcodes to format in a page? Windows 7 64bit can I get bbcodes to format in a page? Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,374
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

If your colours are specified as, for example:
HTML Code:
[color=#0040FF]Disk Cleanup[/color]
then you'd do better to use something like:
Code:
    .Text = "\[color=0040FF\](*)\[/color\]"
    .Replacement.Font.Color = &H40FF
That way, you don't need to find a ColorIndex (which won't exist for some colours) and you'll get a more faithful representation of what the actual colour is (&H40FF is red, not green).
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #10  
Old 04-01-2018, 04:12 PM
matelot2 matelot2 is offline can I get bbcodes to format in a page? Windows 7 64bit can I get bbcodes to format in a page? Office 2003
Novice
can I get bbcodes to format in a page?
 
Join Date: Jul 2017
Posts: 13
matelot2 is on a distinguished road
Default

Thank you Paul,
I have replaced ActiveDocument with Selection
On that line I now have With Selection.Range
I have replaced wdFindContinue with wdFindStop
on that line I now have .Wrap = wdFindStop
I highlight a section and run the macro and it works perfectly.

I have a section that adds a new line increasing the number that replaces the asterisk by one everytime it sees an asterisk in brackets like this
  1. If prompted, select the drive that you want to clean up, and then select OK.
  2. Wait for the box to complete a search, this may be a while depending on the size of the drive.
  3. Once the search is complete a new box will open.
  4. Put a tick in the boxes Temporary Files and Temporary Internet files
  5. Uncheck the tick in any other boxes.
  6. Click OK.

the code is

square bracket list=1 close square bracket
[*]If prompted, select the drive that you want to clean up, and then select OK.
[*]Wait for the box to complete a search, this may be a while depending on the size of the drive.
[*]Once the search is complete a new box will open.
[*]Put a tick in the boxes Temporary Files and Temporary Internet files
[*]Uncheck the tick in any other boxes.
[*]Click OK.
square bracket /list close square bracket
Reply With Quote
  #11  
Old 04-01-2018, 04:17 PM
macropod's Avatar
macropod macropod is offline can I get bbcodes to format in a page? Windows 7 64bit can I get bbcodes to format in a page? Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,374
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Presumably you mean the code for the list is something like:
HTML Code:
[list=1]
[*]If prompted, select the drive that you want to clean up, and then select OK.
[*]Wait for the box to complete a search, this may be a while depending on the size of the drive.
[*]Once the search is complete a new box will open.
[*]Put a tick in the boxes Temporary Files and Temporary Internet files 
[*]Uncheck the tick in any other boxes.
[*]Click OK. 
[/list]
Please confirm.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #12  
Old 04-01-2018, 05:57 PM
matelot2 matelot2 is offline can I get bbcodes to format in a page? Windows 7 64bit can I get bbcodes to format in a page? Office 2003
Novice
can I get bbcodes to format in a page?
 
Join Date: Jul 2017
Posts: 13
matelot2 is on a distinguished road
Default

I hope you did that tongue-in-cheek
I tried it with the # tag and it didn't work I didn't try it with the <> like this
HTML Code:
[list=1]
[*]If prompted, select the drive that you want to clean up, and then select OK.
[*]Wait for the box to complete a search, this may be a while depending on the size of the drive.
[*]Once the search is complete a new box will open.
[*]Put a tick in the boxes Temporary Files and Temporary Internet files 
[*]Uncheck the tick in any other boxes.
[*]Click OK. 
[/list]
Yes that is it.
Reply With Quote
  #13  
Old 04-01-2018, 06:15 PM
macropod's Avatar
macropod macropod is offline can I get bbcodes to format in a page? Windows 7 64bit can I get bbcodes to format in a page? Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,374
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

For that you could use code like:
Code:
Sub DemoII()
Application.ScreenUpdating = False
Dim RngSel As Range, RngTmp As Range, i As Long, j As Long
With Selection
  Set RngSel = .Range
  With .Range
    With .Find
      .ClearFormatting
      .Replacement.ClearFormatting
      .Text = "\[list=[0-9]\]*\[/list\]"
      .Replacement.Text = ""
      .Forward = True
      .Wrap = wdFindStop
      .Format = False
      .MatchWildcards = True
      .Execute
    End With
    Do While .Find.Found
      If .InRange(RngSel) = False Then Exit Do
      i = CLng(Split(Split(.Text, "]")(0), "=")(1)) - 1
      j = 0
      Set RngTmp = .Duplicate
      With .Duplicate
        .Paragraphs.First.Range.Text = vbNullString
        .Paragraphs.Last.Range.Text = vbNullString
        With .Find
          .ClearFormatting
          .Replacement.ClearFormatting
          .Text = "\[\*\]"
          .Replacement.Text = ""
          .Forward = True
          .Wrap = wdFindStop
          .Format = False
          .MatchWildcards = True
          .Execute
        End With
        Do While .Find.Found
          j = j + 1
          If .InRange(RngTmp) = False Then Exit Do
          .Text = i + j & ". "
          .Collapse wdCollapseEnd
          .Find.Execute
        Loop
      End With
      .Collapse wdCollapseEnd
      .Find.Execute
    Loop
  End With
End With
RngSel.Select
Set RngSel = Nothing:Set RngTmp = Nothing
Application.ScreenUpdating = True
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #14  
Old 04-02-2018, 04:50 AM
matelot2 matelot2 is offline can I get bbcodes to format in a page? Windows 7 64bit can I get bbcodes to format in a page? Office 2003
Novice
can I get bbcodes to format in a page?
 
Join Date: Jul 2017
Posts: 13
matelot2 is on a distinguished road
Default

Thank you Paul. that works perfectly and is almost what I want.
I am trying to merge them into one macro. If I run them independently they work perfectly.
If I remove the End Sub from one and the Sub from the next they look to mould into one but only the first gets performed.
I have tried a few ways to get them to work as one file but without any luck.
this is the full file. I have left a gap between the two files you sent me and just removed the Sub <name> End Sub lines
Code:
Sub bbtoword()
'
' bbtoword Macro
' Macro created 01/04/2018 by Bob
'

Application.ScreenUpdating = False
With Selection.Range
  With .Find
    .ClearFormatting
    .Replacement.Text = "\1"
    .Format = False
    .Forward = True
    .Wrap = wdFindStop
    .MatchWildcards = True
    
    .Replacement.ClearFormatting
    .Text = "\[b\](*)\[/b\]"
    .Replacement.Font.Bold = True
    .Execute Replace:=wdReplaceAll
    
    .Replacement.ClearFormatting
    .Text = "\[i\](*)\[/i\]"
    .Replacement.Font.Italic = True
    .Execute Replace:=wdReplaceAll
    
    .Replacement.ClearFormatting
    .Text = "\[u\](*)\[/u\]"
    .Replacement.Font.Underline = True
    .Execute Replace:=wdReplaceAll
    
    .Replacement.ClearFormatting
    .Text = "\[color=blue\](*)\[/color\]"
    .Replacement.Font.ColorIndex = wdBlue
    .Execute Replace:=wdReplaceAll
    
    .Text = "\[color=red\](*)\[/color\]"
    .Replacement.Font.ColorIndex = wdRed
    .Execute Replace:=wdReplaceAll
    
    .Text = "\[color=#0040FF\](*)\[/color\]"
    .Replacement.Font.ColorIndex = wdGreen
    .Execute Replace:=wdReplaceAll
    
  End With
End With
Application.ScreenUpdating = True






Application.ScreenUpdating = False
Dim RngSel As Range, RngTmp As Range, i As Long, j As Long
With Selection
  Set RngSel = .Range
  With .Range
    With .Find
      .ClearFormatting
      .Replacement.ClearFormatting
      .Text = "\[list=[0-9]\]*\[/list\]"
      .Replacement.Text = ""
      .Forward = True
      .Wrap = wdFindStop
      .Format = False
      .MatchWildcards = True
      .Execute
    End With
    Do While .Find.Found
      If .InRange(RngSel) = False Then Exit Do
      i = CLng(Split(Split(.Text, "]")(0), "=")(1)) - 1
      j = 0
      Set RngTmp = .Duplicate
      With .Duplicate
        .Paragraphs.First.Range.Text = vbNullString
        .Paragraphs.Last.Range.Text = vbNullString
        With .Find
          .ClearFormatting
          .Replacement.ClearFormatting
          .Text = "\[\*\]"
          .Replacement.Text = ""
          .Forward = True
          .Wrap = wdFindStop
          .Format = False
          .MatchWildcards = True
          .Execute
        End With
        Do While .Find.Found
          j = j + 1
          If .InRange(RngTmp) = False Then Exit Do
          .Text = i + j & ". "
          .Collapse wdCollapseEnd
          .Find.Execute
        Loop
      End With
      .Collapse wdCollapseEnd
      .Find.Execute
    Loop
  End With
End With
RngSel.Select
Set RngSel = Nothing: Set RngTmp = Nothing
Application.ScreenUpdating = True
End Sub

This is the file I am using for the tests. It works when I run the files independently.

HTML Code:
[b]How to empty your[color=#0040FF] Temporary Files [/color] and [color=#0040FF]Temporary Internet files [/color]  using[color=#0040FF] Disk Cleanup. [/color] [/b]
[list=1]
[*]Go to and click on the [b][color=#0040FF]start [/color][/b]button on the left of the task bar.
[*]Click on [b][color=#0040FF]all programs[/color][/b] then  [b]
[color=#0040FF]accessories/system tools/Disk Cleanup.[/color][/b]
[*]If prompted, select the drive that you want to clean up, and then select OK.
[*]Wait for the box to complete a search, this may be a while depending on the size of the drive.
[*]Once the search is complete a new box will open.
[*]Put a tick in the boxes  [b][color=#0040FF]Temporary Files [/color] and [color=#0040FF]Temporary Internet files[/color][/b] 
[*]Uncheck the tick in any other boxes.
[*]Click [b]OK.[/b]
[/list]
Is it possible to combine them and what am I missing?

Are you sure 0040FF is red? I in fact got mixed up between the green we use for comments to each other on the forum and the wording of my test piece, the colour is blue on the forum?

Thanks.
Reply With Quote
  #15  
Old 04-02-2018, 04:52 AM
matelot2 matelot2 is offline can I get bbcodes to format in a page? Windows 7 64bit can I get bbcodes to format in a page? Office 2003
Novice
can I get bbcodes to format in a page?
 
Join Date: Jul 2017
Posts: 13
matelot2 is on a distinguished road
Default

Quote:
then you'd do better to use something like:
Code:
.Text = "\[color=0040FF\](*)\[/color\]"
.Replacement.Font.Color = &H40FF
I can't get the visual basic to accept &H40FF or any combination I have tried?

I put the numbers in back to front i.e. &H40FF becomes &HFF0400 and it works? I now get blue
If you scroll down https://htmlcolorcodes.com/ about the middle you get

# XX XX XX
by putting them into my macro back to front the colours show up.
It deletes the leading '0's so I am going to keep playing and see what I find.

It accepts &HFF for red (i.e. 0000FF with the leading 0s' removed)
It accepts &HFF0000 for blue
but it won't accept &HFF00 for green (even if I put &H00FF00)
It accepts &H04FF00 for a paler green? (that it changes to &H4FF00) and &H01FF00 (that it changes to &H1FF00)
&H018000 is a better green. changed to &H18000.

I am also looking at size
I opened up your program so the different instructions are in blocks of 4 like this

.Replacement.ClearFormatting
.Text = "\[b\](*)\[/b\]"
.Replacement.Font.Bold = True
.Execute Replace:=wdReplaceAll

.Replacement.ClearFormatting
.Text = "\(*)\" (size code removed to stop it changing size)
.Replacement.Font.Size = &H16
.Execute Replace:=wdReplaceAll

It looks as if different forums use different ways of changing size,
this one uses
HTML Code:
[SIZE="5"][/SIZE]
where the one I am doing all this on uses
HTML Code:
[size=150][/size]
** they are both similar. I can use size=150 here and it works. If I hit the 'sizes' box above it gives me "5".
What do you think is the word equivalent of this?
I tried &H16 as above .Replacement.Font.Size = &H16
but the macro crashes with that?

Last edited by matelot2; 04-02-2018 at 03:08 PM.
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
APA format without cover page or references? SoMany Word 0 03-02-2018 10:36 AM
Running Head AND Page Number on First Page of Document (for APA Format) with Word 2003 DBinSJ Word 3 11-23-2016 11:52 AM
word page format bakhtawar12 Word 1 01-22-2015 07:08 PM
can I get bbcodes to format in a page? Changing page format in document by page fiedlerw01 Word 1 10-23-2012 04:10 AM
Web page format Microsoftenquirer1000 Word 1 10-13-2012 06:38 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:19 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft