473,796 Members | 2,601 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Converting Lists from Word to tag-formated plaintext

1 New Member
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 1088

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

Similar topics

11
2936
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
3066
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 and Opera they appear correctly, with a border round both the <DT> and <DD> parts but in Internet Explorer the borders are messed up. Can anyone please tell me where the mistake is? As an aside, the <div id="main"> section should have the...
9
3752
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? Here is an example of just such a usage: <dl class="faq"> <di>
8
5745
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 output html files. The problem is while reading through the worddoc paragraph,the special characters are not identified. So in the xml file,it's just storing that as "?".So I couldn't able to retrive the characters in my ouput html files.
2
5753
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 Explicit On Option Compare Binary
2
4217
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 something like this? I've heard about using the OutPutTo method, but I'm not sure if it can output to a specific bookmark location. Any thoughts?
4
4287
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 is stored in a double linked list, the whole list is sorted for the next round. My problem appears when subjecting the program to heavy load, that is, when I run the simulation for more than 10,000 miliseconds (every event occurs in...
6
5043
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 that resembles the following: <div id="main"> <div class="image">
2
3447
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" and "Insert Row >"; the "Insert Row >" item on the first level invokes, if that's the right word, a second level which has two items, "Above" and "Below". This all worked when it was a ContextMenu. But I am trying to change it to use the new menu...
4
2569
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 code is handling the conversion of RTF text characters and utf characters into HTML entities (e.g. & is being converted to &amp; by the inbuilt php function 'htmlentities')
0
9531
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10459
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10237
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10187
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7553
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6795
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5446
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5578
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3735
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.