Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
![]()
Hi,
I'm trying to insert simple html code into a word document programmatically, the only way I could think of doing this was by adding the html code to the clipboard, and then pasting it in word using an html format. selection.insertXML exists, but only inserts wordML, and I couldn't find any insertHTML other than with the pasteSpecial. However if I have anything above 16 characters (depending on the html tags), I get a (0x800A1066): command failed error. Here is a link http://www.dotnet247.com/247referenc...50/254902.aspx that I based my code on, and his example works fine, but try adding over 20 characters instead of "test" h1testh1 and this error will pop up. Here is what I've done: 'Dim encoder As UTF8Encoding = New UTF8Encoding 'Dim tempStr As String = "123456789012345678901234567890" - this won't work '-------------------------------------------------------- Dim tempStr As String = "test 1brtest 2" Dim htmlText As String = "Version:0.9" & vbCrLf & "StartHTML:-1" & vbCrLf & "EndHTML:-1" & vbCrLf & "StartFragment:000076" & vbCrLf & "EndFragment:000128" & vbCrLf & "!DOCTYPE" & vbCrLf & "HTMLBODYp" & tempStr & "/p/BODY/HTML" Dim clipDO As New System.Windows.Forms.DataObject clipDO.SetData(System.Windows.Forms.DataFormats.Ht ml, htmlText) System.Windows.Forms.Clipboard.SetDataObject(clipD O, True) oApplication.Selection.PasteSpecial(, , , , word.WdPasteDataType.wdPasteHTML) '-------------------------------------------------------- If anyone knows how to successfully insert html code in word, please let me know, I would greatly appreciate it. Thank you, sylvain. |
#2
![]()
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
![]()
What I ended up doing is simply create an html file (u have to add
htmlbody.../body/html or else it won't work even if your htm file appears fine in IE), and inserted it into word using the insertFile() method. That seems to work for me. Thanks. |
Reply |
Thread Tools | |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
take yet another lesson from wordperfect "reveal codes" | Microsoft Word Help | |||
how do i set up template in vbeditor without proggramming language | New Users | |||
Word 2003 Mailmerge problem - works in Word 2000 | Mailmerge | |||
In Word, how can I see all files (*.*) in "save as"? | New Users | |||
WP Delay Code - Word Equiv | Microsoft Word Help |