PDA

View Full Version : [SOLVED:] Format html-content and paste in word-document



kenan
09-02-2014, 04:07 AM
Hi (at)all,
I am developing a vba-script, that reads more html files and paste formatted html-text in word document.

Are there any other solution than except "clipboard". To copy the html-content in die clipboard and paste in word document works, but it is slow!

Know somebody any other solution, how can I html-content paste in word

thanks for your answers!

gmayor
09-02-2014, 04:17 AM
I see a few issues, but the most significant is that html format and Word format are entirely different from one another.
There is however no reason, from your brief description, why you cannot simply open the html document in Word and save it as a Word document.
The resulting document is unlikely to match the format of the web page, because Word is not a browser.

snb
09-02-2014, 04:44 AM
You can use:


Sub M_snb()
ThisDocument.Content = CreateObject("scripting.filesystemobject").opentextfile("G:\Beispiel.html").readall
End Sub

to retrieve the html code in the file G:\Beispeil.html"

if you need several files to be integrated:


Sub M_snb()
for j=1 to 3
ThisDocument.Content.InsertAfter vbCr & CreateObject("scripting.filesystemobject").opentextfile("G:\Beispeil_" & j &".html").readall
next
End Sub

kenan
09-02-2014, 04:48 AM
Hi,
I see, i must say any more about it.

I am develop a ms word template with active buttons. you can create filecards in this word template. A filecard contains a question-area and answer-area. you can create more than one filecards in word document.

1. issue: the content of word must export to xml-file. the xml-file contains all filecards. That is export function to xml. The text in word document formatted as html-content
2. issue: the user can import a xml file, that contains the filecards. the content of xml file will parsed and created filecards.

My problem is: I have 300 and more sets of data in xml-file. every filecard muss parsed and formatted as html-content. If I put the html-content in word-document, text will be autoformatted...

snb
09-02-2014, 05:12 AM
Post a sample of an xml file
Post a sample of the required result in Word.