Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / March 2006

Tip: Looking for answers? Try searching our database.

Is there a way to easily convert html to wordml?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
DarrylR - 02 Mar 2006 12:57 GMT
I Googled this topic last night and discovered that many people have
encountered this problem. However, I didn't find any references to an easy
solution (or, oddly enough, a product). I'm trying to do it from a VSTO
solution created in C# .NET using the primary interop assemblies.

I'm attempting to translate html that incorporates standard formatting tags
(e.g. <b/>,<u/>,<i/>,<sub>,and <sup>), lists (e.g. ul), etc. to something
that can be inserted using the InsertXML method (similar to the code found
at http://blogs.officezealot.com/chris/archive/2003/11/06/1253.aspx below).

Original Sub:
Private Sub InsertWordML()
   Dim sXML As String
   sXML = "<wordDocument
xmlns='http://schemas.microsoft.com/office/word/2003/wordml'><body>" & _
             "<p><r><t xml:space='preserve'>Example of WordML and InsertXML
run at </t></r>" & _
             "</p><p/><p/></body></wordDocument>"
   'Insert WordML
   Selection.InsertXML (sXML)
End Sub

What I'd like to do:
Private Sub InsertWordML()
   Dim sXML As String
   sXML = "<wordDocument
xmlns='http://schemas.microsoft.com/office/word/2003/wordml'
xmlns:ht='http://www.w3.org/TR/REC-html40'>" &_
     "<body><p><r><t xml:space='preserve'><ht:u>Example <ht:b>of
WordML</ht:b> and InsertXML</ht:u></t></r>" &_
     "</p><p/><p/></body></wordDocument>"
   'Insert WordML
   Selection.InsertXML (sXML)
End Sub

I found some references to SpreadsheetML accepting HTML using the following
syntax:
<ss:Data ss:Type='String'
xmlns='http://www.w3.org/TR/REC-html40'>hi<U>there</U> everyone</ss:Data>.

Is there a WordML equivalent syntax?

Thanks in advance,
Darryl R.
DarrylR - 03 Mar 2006 01:09 GMT
I ended up using the Range.InsertFile method for now. It means writing an
html file to disk temporarily, but I found that it's not too expensive in
terms off performance.

Regards,
Darryl R.

> I Googled this topic last night and discovered that many people have
> encountered this problem. However, I didn't find any references to an easy
[quoted text clipped - 40 lines]
> Thanks in advance,
> Darryl R.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.