Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Clipboard contents HTML, paste in WORD no mark-up
#1
When I try to process QM code (converted to HTML) and I paste it in word, nothing get's pasted.
For example, I run the code below If I then paste in WORD it pastes nothing of _s in stead of:

Macro Macro14
Code:
Copy      Help
;GREEN COMMENT TEXT

The code I run:

Macro Macro14
Code:
Copy      Help
_s=
;<style>#r368103{background-color:#FFFFFF;border:#D1D7DC;border-style:solid;border-width:1px;padding-left:2px;line-height:normal;color:black}#r368103,#r368103 *{font-family:'Courier New';font-size:100%}#r368103 .c{color:#008000}#r368103 .c2{color:#008000}#r368103 .s{color:#a07040}#r368103 .n{color:#a04000}#r368103 .o{color:#0000ff}#r368103 .p{color:#ff0000}#r368103 .fq{color:#0000ff}#r368103 .fu{color:#0080f0}#r368103 .fd{color:#8080ff}#r368103 .dir{color:#ff4040}#r368103 .t{color:#c000c0}#r368103 .d{color:#808000}#r368103 .lib{color:#808080}#r368103 .r{color:#008000;font-style:italic}#r368103 .mi{color:#ff00ff}#r368103 .i{color:#e0e0e0;text-decoration:underline}</style>
;<pre id=r368103><span class=c>;GREEN COMMENT TEXT</span></pre>

_s.setclip("HTML format") ;; After running this code, and then pasting in WORD, nothing get's pasted

I got the contents of "_s" by selecting QM code and then right clicking and selecting 'Other formats' > 'Copy HTML'
If I leave out "HTML format" in the setclip command, the actual HTML code get's pasted in stead of marked up "GREEN COMMENT TEXT".

I ran the testcode from the helpfile:

Macro Macro14
Code:
Copy      Help
int f; str s
OpenClipboard 0
rep CountClipboardFormats
,f=EnumClipboardFormats(f)
,s.fix(GetClipboardFormatName(f s s.all(100)))
,out "%i %s" f s
CloseClipboard

And the result was:
Code:
Copy      Help
49433 HTML Format
#2
One thing I've noticed is that if I got the contents like you did by selecting QM code and then right clicking and selecting 'Other formats' > 'Copy HTML'. And if I paste it directly in Word by pressing Ctrl-V then I will get the mark-up as expected.
#3
This menu command copies QM code in 2 clipboard formats: TEXT and HTML Format. Text in TEXT format is HTML without headers, suitable to paste in HTML source editors.
In programs that can display HTML, Ctrl+V usually pastes HTML Format. For example in Word, Thunderbird, WYSIWYG web page editors. In other programs, Ctrl+V pastes TEXT format. For example, in QM, Notepad and in HTML source editors.

In your code, _s does not contain HTML Format. setclip does not convert simple text to HTML Format.
#4
Found this function.

Function PasteHtml
Code:
Copy      Help
;/
function $html

;Pastes text in HTML format.
;Works only with windows that support HTML format. For example, Word.
;Error if the active window does not support HTML format.

;EXAMPLE
;PasteHtml "<html><body>text <a href=''http://www.quickmacros.com''>Quick Macros</a> text</body></html>"


str sh.format("Version:1.0[]StartHTML:00000033[]%s" html)
sh.setsel("HTML Format")
err end _error
#5
Thank you very much!
This makes it clear!


Forum Jump:


Users browsing this thread: 1 Guest(s)