![]() |
|
|
|
#1
|
||||
|
||||
|
Since, I got suggestion for my this post, https://www.msofficeforums.com/word-...data-word.html, I was able to extract web data from word as HTML or as palin text. I searched, but I think there is no method available for Microsoft word user to insert formatted text from HTML especially when the html contains images.
While searching I found out that windows clipboard should contains following format to be pasted as formatted text. Code:
Version:0.9
StartHTML:71
EndHTML:170
StartFragment:140
EndFragment:160
StartSelection:140
EndSelection:160
<!DOCTYPE>
<HTML>
<HEAD>
<TITLE> The HTML Clipboard</TITLE>
<BASE HREF="http://sample/specs">
</HEAD>
<BODY>
<UL>
<!--StartFragment -->
<LI> The Fragment </LI>
<!--EndFragment -->
</UL>
</BODY>
</HTML>
There is need for word users to be able to paste HTML string as formatted text. |
|
#2
|
||||
|
||||
|
Code:
Selection.PasteAndFormat (wdFormatOriginalFormatting)
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
|
#3
|
||||
|
||||
|
Sorry for not making it clear.
I am not talking about pasting formatted text from clipboard. I am talking about putting HTML to clipboard in such way recognized by windows clipboard format (code in post 1) to paste it as formatted text. |
|
#4
|
||||
|
||||
|
Did you try simply copying the web extract to the clipboard (CTRL+C) then use the macro?
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
|
#5
|
||||
|
||||
|
Yes sir. It give plain html if copy paste the web extract. Web extract is in HTML formate like
My StrTxt contains Code:
<DIV class=someclass> <DIV id=class-00001 class=class num="00001"> so many such lines with <src = embedded image> <DIV></DIV> Code:
so many such lines with (inline embedded image). Code:
Set IE = CreateObject("InternetExplorer.Application")
With IE
.Visible = False
.navigate "about:blank"
.Document.body.innerHTML = StrTxt
.Document.execCommand "SelectAll"
.Document.execCommand "Copy"
.Quit
.Quit 'to make sure.
End With
Set IE = Nothing
Set Rng = Tbl.Cell(i, 5).Range
Rng.Collapse wdCollapseStart
Rng.PasteAndFormat wdPasteDefault
Set Rng = Nothing
|
|
| Tags |
| vba, wordvba |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Adding a oval shape in word and pasting image into it from clipboard | choper | Word VBA | 5 | 06-15-2015 01:04 AM |
Shift key is pasting from clipboard...WHY?
|
nc1105 | Word | 2 | 01-02-2014 11:57 PM |
| Pasting image captured with a java program 'on to clipboard' into MSWord 2007 is blur | tarunkumarreddy | Word | 0 | 02-03-2012 09:42 PM |
| Import formatted text from Word into PowerPoint | parboy | PowerPoint | 0 | 07-06-2011 08:52 AM |
| How to make page footers in html formatted .doc file? | equalizer700 | Word | 0 | 01-27-2011 02:30 PM |