-
Notifications
You must be signed in to change notification settings - Fork 72
/
HTML2RTF.ahk
75 lines (68 loc) · 1.65 KB
/
HTML2RTF.ahk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
;**************************
;HTML2RTF Converter for AutoHotKey
;Made by DigiDon from Hanleyk1's code
;**************************
sRTF_To_HTML(ByRef sRTF) {
global wc
sReturnString := ""
sConvertedString := ""
try {
; 'Instantiate the Word application,
; ‘set visible to false and create a document
MyWord:=ComObjActive("Word.Application")
MyWord.Visible := False
NotesDoc := MyWord.Documents.Add()
wc.SetRTF(sRTF)
MyWord.Selection.Paste()
MyWord.Selection.WholeStory()
MyWord.Selection.Copy()
sConvertedString := wc.GetHTML()
sReturnString := sConvertedString
If (MyWord=!"")
{
MyWord.Quit(0)
MyWord := ""
}
}
catch e {
If (MyWord=!"")
{
MyWord.Quit(0)
MyWord := ""
}
MsgBox % "Error converting Rich Text to HTML"
}
Return sReturnString
}
sHTML_To_RTF(ByRef sHTML) {
global wc
sReturnString := ""
sConvertedString := ""
try {
; 'Instantiate the Word application,
; ‘set visible to false and create a document
MyWord:=ComObjActive("Word.Application")
MyWord.Visible := False
NotesDoc := MyWord.Documents.Add()
wc.SetHTML(sHTML)
MyWord.Selection.Paste()
MyWord.Selection.WholeStory()
MyWord.Selection.Copy()
sConvertedString := wc.GetRTF()
sReturnString := sConvertedString
If (MyWord=!"")
{
MyWord.Quit(0)
MyWord := ""
}
}
catch e {
If (MyWord=!"")
{
MyWord.Quit(0)
MyWord := ""
}
MsgBox % "Error converting HTML to Rich Text"
}
Return sReturnString
}