![]() |
|
#1
|
|||
|
|||
![]()
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]. Disk Cleanup Click Start and then click Run.... Thanks. Last edited by matelot2; 03-31-2018 at 02:34 PM. Reason: alter title |
#2
|
||||
|
||||
![]()
Not unless you run a macro to convert the tags to formatting for you.
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
#3
|
|||
|
|||
![]()
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 |
#4
|
|||
|
|||
![]()
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. |
#5
|
||||
|
||||
![]()
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
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#6
|
|||
|
|||
![]()
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. |
#7
|
|||
|
|||
![]()
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. |
#8
|
||||
|
||||
![]()
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] |
#9
|
||||
|
||||
![]()
If your colours are specified as, for example:
HTML Code:
[color=#0040FF]Disk Cleanup[/color] Code:
.Text = "\[color=0040FF\](*)\[/color\]" .Replacement.Font.Color = &H40FF
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#10
|
|||
|
|||
![]()
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
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 |
#11
|
||||
|
||||
![]()
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]
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#12
|
|||
|
|||
![]()
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] ![]() |
#13
|
||||
|
||||
![]()
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] |
#14
|
|||
|
|||
![]()
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] 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. |
#15
|
|||
|
|||
![]() Quote:
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] HTML Code:
[size=150][/size] 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. |
![]() |
|
![]() |
||||
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 |
![]() |
fiedlerw01 | Word | 1 | 10-23-2012 04:10 AM |
Web page format | Microsoftenquirer1000 | Word | 1 | 10-13-2012 06:38 AM |