各位高手,我们公司让我临时做一个小的vb程序,以前没有做过,通过论坛我编写的文件如下,但是经过测试,总是说函数或变量未定义,不知为何,最后一部还请各位能够帮忙
Const WINSYSTEM = False
Const TMPPATH = "E:\"
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Sub printhtml(htmlContent As String)
Send "Status: 200 OK"
Send "Content-type: text/html" & vbCrLf
Send "<HTML><HEAD><TITLE>Message from CGI</TITLE></HEAD>"
Send "<BODY>"
Send htmlContent
Send "</BODY></HTML>"
End Sub Sub CGI_Main()
Dim upfile As String
Dim fullname As String
Dim htmname As String
upfile = GetCgiValue("a")
'upfile = "file"
If Len(upfile) Then
If WINSYSTEM Then
Sleep 10000
End If
Dim WordApp As New Word.Application
fullname = TMPPATH & upfile & ".doc"
htmname = TMPPATH & upfile & ".htm"
WordApp.Visible = True
WordApp.DisplayAlerts = wdAlertsNone
WordApp.Documents.Open fullname
'adjust the format
With WordApp
For Each sty In .ActiveDocument.Styles
If sty.BuiltIn = False And sty.NameLocal = "CorrectAnswer" Then
.ActiveDocument.Styles("CorrectAnswer").LinkToListTemplate ListTemplate:=Nothing
End If
If sty.BuiltIn = False And sty.NameLocal = "IncorrectAnswer" Then
.ActiveDocument.Styles("IncorrectAnswer").LinkToListTemplate ListTemplate:=Nothing
End If
Next sty
With .ActiveDocument.WebOptions
.Encoding = 65001
.RelyOnCSS = True
.OptimizeForBrowser = True
.BrowserLevel = 0
.OrganizeInFolder = True
.UseLongFileNames = True
.RelyOnVML = False
.AllowPNG = False
.ScreenSize = msoScreenSize800x600
.PixelsPerInch = 96
End With
'ActiveDocument.WebOptions.
.ActiveDocument.SaveAs htmname, 10
.ActiveDocument.Close
End With
WordApp.Quit SaveChanges:=wdDoNotSaveChanges
If WINSYSTEM Then
Sleep 10000
End If
printhtml ("Success")
Else
printhtml ("No file uploaded")
End If
End SubPrivate Sub CmdDoc_Click()
Call CGI_Main
End Sub
Const WINSYSTEM = False
Const TMPPATH = "E:\"
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Sub printhtml(htmlContent As String)
Send "Status: 200 OK"
Send "Content-type: text/html" & vbCrLf
Send "<HTML><HEAD><TITLE>Message from CGI</TITLE></HEAD>"
Send "<BODY>"
Send htmlContent
Send "</BODY></HTML>"
End Sub Sub CGI_Main()
Dim upfile As String
Dim fullname As String
Dim htmname As String
upfile = GetCgiValue("a")
'upfile = "file"
If Len(upfile) Then
If WINSYSTEM Then
Sleep 10000
End If
Dim WordApp As New Word.Application
fullname = TMPPATH & upfile & ".doc"
htmname = TMPPATH & upfile & ".htm"
WordApp.Visible = True
WordApp.DisplayAlerts = wdAlertsNone
WordApp.Documents.Open fullname
'adjust the format
With WordApp
For Each sty In .ActiveDocument.Styles
If sty.BuiltIn = False And sty.NameLocal = "CorrectAnswer" Then
.ActiveDocument.Styles("CorrectAnswer").LinkToListTemplate ListTemplate:=Nothing
End If
If sty.BuiltIn = False And sty.NameLocal = "IncorrectAnswer" Then
.ActiveDocument.Styles("IncorrectAnswer").LinkToListTemplate ListTemplate:=Nothing
End If
Next sty
With .ActiveDocument.WebOptions
.Encoding = 65001
.RelyOnCSS = True
.OptimizeForBrowser = True
.BrowserLevel = 0
.OrganizeInFolder = True
.UseLongFileNames = True
.RelyOnVML = False
.AllowPNG = False
.ScreenSize = msoScreenSize800x600
.PixelsPerInch = 96
End With
'ActiveDocument.WebOptions.
.ActiveDocument.SaveAs htmname, 10
.ActiveDocument.Close
End With
WordApp.Quit SaveChanges:=wdDoNotSaveChanges
If WINSYSTEM Then
Sleep 10000
End If
printhtml ("Success")
Else
printhtml ("No file uploaded")
End If
End SubPrivate Sub CmdDoc_Click()
Call CGI_Main
End Sub
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货