|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Pasting html into Word 2007Word 2007. The code (below) for Word Versions prior to 2007 (12) works fine, but Word 2007 pastes the string as text with the associated html tags displaying on the document. Any ideas on this? Dim oWord As Word.Application Dim oDoc As Word.Document Dim htmlValue as String htmlValue = "<html><body>Test</body></html>" 'Open MS-Word via OLE. Set oWord = CreateObject("word.application") Set oDoc = oWord.Documents.Add() 'get version of word If oWord.Version = 12 Then 'Open a new document with the default template. Dim clipDO As DataObject clipDO.SetData htmlValue Clipboard.SetText htmlValue 'Add text to the document. 'Displays with html tags on page. oWord.Selection.Paste Else 'This works oWord.ActiveDocument.HTMLProject.HTMLProjectItems(1).Text = htmlValue oWord.ActiveDocument.HTMLProject.RefreshDocument End If 'Display MS-Word. oWord.Visible = True oWord.Activate Hi Randy,
Does Word have a PasteSpecial in it's programming interface ? If not you might try removing the text from the clipboard and only leave the html format. Show quoteHide quote "Randy" <randel.mc***@oscn.net> wrote in message news:54e2d144-3d86-4258-912c-411a5e7b2349@z9g2000yqi.googlegroups.com... > Hi. I need help. I am having problems pasting an html string into > Word 2007. The code (below) for Word Versions prior to 2007 (12) > works fine, but Word 2007 pastes the string as text with the > associated html tags displaying on the document. Any ideas on this? > > Dim oWord As Word.Application > Dim oDoc As Word.Document > Dim htmlValue as String > > > htmlValue = "<html><body>Test</body></html>" > > > 'Open MS-Word via OLE. > Set oWord = CreateObject("word.application") > Set oDoc = oWord.Documents.Add() > > > 'get version of word > If oWord.Version = 12 Then > 'Open a new document with the default template. > Dim clipDO As DataObject > clipDO.SetData htmlValue > > > Clipboard.SetText htmlValue > > > 'Add text to the document. > 'Displays with html tags on page. > oWord.Selection.Paste > > > Else > 'This works > oWord.ActiveDocument.HTMLProject.HTMLProjectItems(1).Text = > htmlValue > oWord.ActiveDocument.HTMLProject.RefreshDocument > End If > > > 'Display MS-Word. > oWord.Visible = True > oWord.Activate > >
How to make this call from form to control
Differences between VB amd VBA and VBA Education Application.Quit but Word remains open in Task Manager VB App fails when log reaches 65536 HOW IS Memory Used by a VB App vb.net executing on Help with Binary Compatibility Fonts Knowing what launched an EXE that used CreateProcess()? Internal String Visibility |
|||||||||||||||||||||||