473,407 Members | 2,320 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

Converting Lists from Word to tag-formated plaintext

Hi fellow VB knowers (I am but a learner still).

I have a question for you which I struggle with. I need to convert nested Lists in MS WORD (whether numbered or bulleted or mixed) from their original format to a tag-formatted text (as used for instance for Wiki articles or phpBB Forums and such). In my particular case I need the text to have basic HTML tags for the basic formatting - e.g. <strong>text</strong> or <em>italics</em> - and this final text is used for a Drupal web-system which does the article formatting based on these simplified (or rather reduced) HTML tags.

The basics as Bold or Italics or Headings is not the problem, as I found the Word2MediaWiki macro for Word and edited it to my purposes (mainly giving pre- and post-tags to blocks of given formatting). I also have figured basic Lists, using non-nested items.

What I have problem figuring out how to do are the nested Lists, either numbered (mixed), bulleted (mixed) or totally mixed. The final output should be something like this:

Expand|Select|Wrap|Line Numbers
  1. <OL TYPE="1">
  2. <LI>List Item 1
  3. <OL TYPE="a">
  4. <LI>Nested List Item 1
  5. <LI>Nested List Item 2
  6. </OL>
  7. <LI>List Item 2
  8. <UL>
  9. <LI>Nested List Item 1</UL>
  10. <LI>List Item 3
  11. <LI>List Item 4
  12. </OL>
The macro part for Lists that I am using (and which is working fine with normal, non-nested lists) is this:

Expand|Select|Wrap|Line Numbers
  1. Private Sub RPGskConvertLists()
  2.  
  3.     Dim zoznam As List
  4.  
  5.     For Each zoznam In ActiveDocument.Lists
  6.         With zoznam.Range
  7.             If .ListFormat.ListType = wdListBullet Then
  8.                 .InsertAfter "</ul>"
  9.             Else
  10.                 .InsertAfter "</ol>"
  11.             End If
  12.         End With
  13.     Next zoznam
  14.  
  15.  
  16.     Dim para As Paragraph
  17.     For Each para In ActiveDocument.ListParagraphs
  18.         With para.Range
  19.             For i = 1 To .ListFormat.ListLevelNumber
  20.                 .InsertBefore "<li>"
  21.                 .InsertAfter "</li>"
  22.             Next i
  23.         End With
  24.      Next para
  25.  
  26.     For Each zoznam In ActiveDocument.Lists
  27.         With zoznam.Range
  28.             If .ListFormat.ListType = wdListBullet Then
  29.                 .InsertBefore "<ul>"
  30.             Else
  31.                 .InsertBefore "<ol>"
  32.             End If
  33.  
  34.             .ListFormat.RemoveNumbers
  35.  
  36.         End With
  37.     Next zoznam
  38.  
  39. End Sub
If you can help me in any way to get also nested Lists working with this macro, I would be very grateful.

Thx!

Joe
Aug 24 '07 #1
0 1061

Sign in to post your reply or Sign up for a free account.

Similar topics

11
by: vdavidster | last post by:
Hello everyone, I want to convert a tuple to a list, and I expected this behavior: list(('abc','def')) -> list(('abc')) -> But Python gave me this behavior: list(('abc','def')) ->
29
by: Joseph Haig | last post by:
I am trying to use descriptive lists, <DL>, as shown in <http://www.maths.man.ac.uk/~jhaig/tmp/test.html> with a style sheet at <http://www.maths.man.ac.uk/~jhaig/tmp/default-2.css>. With Mozilla...
9
by: Dave H | last post by:
Hello, I have a query regarding definition lists. Is it good practice semantically to use the dt and dd elements to mark up questions and answers in a frequently asked questions list, or FAQ? ...
8
by: prabha | last post by:
Hello Everybody, I have to conert the word doc to multiple html files,according to the templates in the word doc. I had converted the word to xml.Also through Exsl ,had finished the multiple...
2
by: Asbjørn Ulsberg | last post by:
Hi. I'm trying to convert Brady Hegberg's great RTF2HTML VB 6.0 module to C#. I've managed to convert the VB code to VB.NET, which gave me the following code: Option Strict On Option...
2
by: fordesky | last post by:
Gday, I have a set of Access 2000 tables that I would like to export into a MS Word 2000 template at specific bookmark locations that I've set up. Would anyone know the code to achieve...
4
by: FBM | last post by:
Hi, I am working on a program that simulates one of the elements of ATM. The simulation stores events which occurs every some milliseconds for a certain amount of time. Every time that an event...
6
by: mno | last post by:
Hi all, I have a problem that I've been stuck with for the last couple of days that's driving me a bit more than crazy at this point. Sorry if this message is not very clear. I have a design...
2
by: eBob.com | last post by:
I've been working on an app which has an array of RichTextBoxes. And I have a context menu for the RTBs. The context menu has two levels; the first level has two items, "Load Sample Text File"...
4
by: BG Mahesh | last post by:
hi We are using the normal html controls (textarea) in the posting form. The form page has the utf-8 character set. Users are copying the text from MS Word or Openoffice doc etc. Our PHP...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.