Convert Word document to BBcode

To be honest I will provide you with a macro script for MS Word, which is not written by me, and it was taken from the phpBB community Word to BBcode Macro. This Visual Basic BBCode converter is really useful when you have CMS which is using BBCode, but in the same time does not provide enough options for easy management. Then every text you write, must be gone trough and where you have bold, italic, bolditalic, URL, , must be surrounded with the correct BB code. This is rather annoying especially when you want to mark frequently different keyword for your SEO.

The Word2BBCode-Converter is written on June 2, 2006 by Matthew Kruer,as some parts are adapted from \”Word2Wiki-Converter\”. Major improvements were made by Gunter Schmidt.
The BBCode converter works with MS Word XP,2000 and above. The current license is GPL, which means that you are free to use and modify, but you have to keep the credits and do not sell.

Copy the Word to BBCode converter, from the above field and save it as a .bas file(for example w2bb.bas).
To load the script, open your MS Word and expand the Macro section where you will find the Visual Basic editor.
Import the script from File -> Import File.

Convert Word document to BBcode

Once the Word to BBCode converter is imported either click ‘F5’, or go to ‘Run’ and then click ‘Run Macro’.
Then go back to MS Word and you will see your document converted.

The script is working perfect for me.
There is only one bug that happens, but I have not reported it yet since I am not sure what causing it. I think on a specific hidden character it just cannot end the \"while\" cycle.

The only resolution is to copy and paste the text in Notepad and then in a clean MS Word document. Unfortunately you will loose any formatting made.

Convert Word document to BBcode


Filed Under: Visual Basic

Anthony Gee About the Author: Anthony G. is an IT specialist with more than 9 years of solid working experience in the Web Hosting industry. Currently works as server support administrator, involved in consultative discussions about Web Hosting and server administration. One of the first writers in the website, now writing for Free Tutorials community - he is publishing tutorials and articles for the wide public, as well as specific technical solutions.

Comments (11)

  1. Cape Codder says:

    Nice…seems to work well

  2. Sharon says:

    For Office 7, when importing, I get an error on this line:

    If Mid$(addr, Len(addr) ‘“ 3, 1) = “.” Then

  3. Anthony Gee says:

    Hi Sharon, I am not able to recreate the error. It took time to find Office 7 to check it, which is the reason why I am answering so late.

    Provide more details about the error.

  4. Anthony Gee Anthony Gee says:

    This’ really odd, I am still using this script. I will play around with it and will provide solution if it is possible.

  5. Adam says:

    I get the same problem: error is syntax Error and its MS 2k7
    If Mid$(addr, Len(addr) ‘“ 3, 1) = “.” Then

    • Anthony Gee Anthony Gee says:

      Yes, It seams they changed the syntax in MS 2k7. I will collect some info about how the syntax should be changed.

      • Juan says:

        Hey, did you ever find how to replace that syntax? It would be a really useful script if I could run it. Please :)

        • Anthony Gee Anthony Gee says:

          I tried several things, but it still works fine only for Office XP

          • Aaron W says:

            I seem to have fixed it. It works for me now with MS Word 2007. Try replacing this line:
            If Mid$(addr, Len(addr) ‘“ 3, 1) = ‘.’ Then

            with these two lines:
            tmp = Len(addr) – 3
            If Mid$(addr, tmp, 1) = “.” Then

            I’m not very familiar with Visual Basic (so I’m not exactly sure why this worked!), but I’m guessing it has to do with data types and evaluating expressions within a function call (Mid$ requires an input of type Long for its second argument). Just guessing, though. And there’s probably a more elegant way to do it.

Leave a Reply