Changeset 10629

Show
Ignore:
Timestamp:
23.09.2005 11:28:37 (14 years ago)
Author:
chi
Message:

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

Location:
trunk/winbin/bin
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • trunk/winbin/bin/word2html.frm

    r10573 r10629  
    3636 
    3737Private Sub Form_Load() 
    38     Dim wa As Word.Application 
     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     
    3948    Dim cmdln As String 
    4049    Dim src As String 
     
    4352    cmdln = LCase(Command()) 
    4453    'MsgBox ("Command:" + cmdln) 
    45     'cmdln = Chr(34) & "H:\chi\gsdl\collect\WordTest\import\word01.doc" & Chr(34) & Chr(34) & "H:\chi\gsdl\collect\WordTest\tmp\word01.html" & Chr(34) 
     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) 
    4655    src = Trim(Left(cmdln, (InStr(cmdln, ".doc") + 4))) 
    4756    src = Mid(src, 2, Len(src) - 2) 
     57    'MsgBox ("Src:" + src) 
    4858    If InStr(src, ":") <> 2 Then src = CurDir + "\" + src 
    49      
    5059    dst = Trim(Right(cmdln, Len(cmdln) - (InStr(cmdln, ".doc") + 4))) 
    5160    dst = Mid(dst, 2, Len(dst) - 2) 
    5261    If InStr(dst, ":") <> 2 Then dst = CurDir + "\" + dst 
    5362         
    54     'Creat a Word Application 
    55     Set wa = CreateObject("Word.application") 
    56     wa.Visible = True 
    5763     
    58     'Open a Word Document 
    59     Dim wd As Word.Documents 
    60     Set wd = wa.Documents 
     64    'Create a Word Document Object and Open a Word Document 
     65    Dim objWD As Object 
     66    Set objWD = objWA.Documents 
    6167     
    62     wd.Open (src) 
    63     'wd(1).SaveAs dst, HTMLFileFormat(); 
    64     wd(1).SaveAs dst, wdFormatHTML 
    65         
    66     wd(1).Close 
     68    objWD.Open (src) 
     69    objWD(1).SaveAs dst, wdFormatHTML 
     70    objWD(1).Close 
    6771 
    6872    ' Quite Word Application 
    69     wa.Quit 
     73    objWA.Quit 
    7074     
    7175    'Release Objects 
    72     Set wa = Nothing 
    73     Set wd = Nothing 
     76    Set objWA = Nothing 
     77    Set objWD = Nothing 
    7478 
    7579    End 
  • trunk/winbin/bin/word2html.vbp

    r10573 r10629  
    11Type=Exe 
    2 Reference=*\G{00020430-0000-0000-C000-000000000046}#2.0#0#C:\WINDOWS\system32\STDOLE2.TLB#OLE Automation 
     2Reference=*\G{00020430-0000-0000-C000-000000000046}#2.0#0#C:\WINDOWS\system32\stdole2.tlb#OLE Automation 
    33Reference=*\G{91493440-5A91-11CF-8700-00AA0060263B}#2.7#0#C:\Program Files\Microsoft Office\OFFICE11\MSPPT.OLB#Microsoft PowerPoint 10.0 Object Library 
    44Reference=*\G{00020905-0000-0000-C000-000000000046}#8.2#0#C:\Program Files\Microsoft Office\OFFICE11\MSWORD.OLB#Microsoft Word 10.0 Object Library 
  • trunk/winbin/bin/word2html.vbw

    r10574 r10629  
    1 Form1 = -411, 30, 601, 642, C, 44, 58, 1056, 670, C 
     1Form1 = -411, 30, 601, 642, Z, 44, 58, 1056, 670, C