source: trunk/winbin/bin/word2html.frm@ 10629

Last change on this file since 10629 was 10629, checked in by chi, 19 years ago

Modify word2html VB script by using late binding technique to solve the problem of running the
MS office Automation script for multiple office versions.

  • Property svn:keywords set to Author Date Id Revision
File size: 3.5 KB
Line 
1VERSION 5.00
2Begin VB.Form Form1
3 Caption = "Form1"
4 ClientHeight = 1380
5 ClientLeft = 60
6 ClientTop = 450
7 ClientWidth = 3825
8 LinkTopic = "Form1"
9 ScaleHeight = 1380
10 ScaleWidth = 3825
11 StartUpPosition = 3 'Windows Default
12 Begin VB.Label W
13 Alignment = 2 'Center
14 Caption = "Word to HTML"
15 BeginProperty Font
16 Name = "MS Sans Serif"
17 Size = 24
18 Charset = 0
19 Weight = 400
20 Underline = 0 'False
21 Italic = 0 'False
22 Strikethrough = 0 'False
23 EndProperty
24 Height = 615
25 Left = 360
26 TabIndex = 0
27 Top = 360
28 Width = 3375
29 End
30End
31Attribute VB_Name = "Form1"
32Attribute VB_GlobalNameSpace = False
33Attribute VB_Creatable = False
34Attribute VB_PredeclaredId = True
35Attribute VB_Exposed = False
36
37Private Sub Form_Load()
38 'For solving the backward compatability of MS Automation with VB script
39 'We need to use the late binding technique, in which mean that we need to
40 'define all Office Automation variable as an Object first and it can then
41 'to decide the office version at run-tim.
42
43 'Creat a Word Application
44 Dim objWA As Object
45 Set objWA = CreateObject("Word.Application")
46 objWA.Visible = True
47
48 Dim cmdln As String
49 Dim src As String
50 Dim dst As String
51
52 cmdln = LCase(Command())
53 'MsgBox ("Command:" + cmdln)
54 'cmdln = Chr(34) & "H:\chi\gsdl\collect\WordTest\import\word03_01.doc" & Chr(34) & Chr(34) & "H:\chi\gsdl\collect\WordTest\tmp\word03_01.html" & Chr(34)
55 src = Trim(Left(cmdln, (InStr(cmdln, ".doc") + 4)))
56 src = Mid(src, 2, Len(src) - 2)
57 'MsgBox ("Src:" + src)
58 If InStr(src, ":") <> 2 Then src = CurDir + "\" + src
59 dst = Trim(Right(cmdln, Len(cmdln) - (InStr(cmdln, ".doc") + 4)))
60 dst = Mid(dst, 2, Len(dst) - 2)
61 If InStr(dst, ":") <> 2 Then dst = CurDir + "\" + dst
62
63
64 'Create a Word Document Object and Open a Word Document
65 Dim objWD As Object
66 Set objWD = objWA.Documents
67
68 objWD.Open (src)
69 objWD(1).SaveAs dst, wdFormatHTML
70 objWD(1).Close
71
72 ' Quite Word Application
73 objWA.Quit
74
75 'Release Objects
76 Set objWA = Nothing
77 Set objWD = Nothing
78
79 End
80End Sub
81Function getoutput(line)
82 cmdln = line
83 While InStr(cmdln, ".ppt")
84 cmdln = LTrim(Right(cmdln, Len(cmdln) - (InStr(cmdln, ".ppt") + 3)))
85 Wend
86 If Right(CurDir, 1) = "\" Then cmdln = CurDir + cmdln Else cmdln = CurDir + "\" + cmdln
87 If LTrim(cmdln) = "" Then cmdln = cmdln + "out"
88 If Right(cmdln, 1) <> "\" Then cmdln = cmdln + "\"
89 getoutput = cmdln
90End Function
91
92Function getargs(line)
93 x = LTrim(line)
94 If InStr(x, "-") = 1 Then
95 getargs = Left(line, InStr(line, " "))
96 End If
97End Function
98
99Function getdir(line)
100 x = LTrim(Right(line, Len(line) - Len(getargs(line))))
101 If InStr(x, ":") <> 2 Then
102 direc = CurDir
103 If Right(direc, 1) <> "\" Then direc = direc + "\"
104 End If
105
106 While InStr(x, "\")
107 direc = direc + Left(x, InStr(x, "\"))
108 x = Right(x, Len(x) - InStr(x, "\"))
109 Wend
110 getdir = direc
111End Function
112
113Function getfile(line)
114 x = LTrim(Right(line, Len(line) - Len(getargs(line))))
115 While InStr(x, "\")
116 x = Right(x, Len(x) - InStr(x, "\"))
117 Wend
118 getfile = x
119End Function
Note: See TracBrowser for help on using the repository browser.