⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 docfunc.vbs

📁 办公自动化系统
💻 VBS
字号:
'<%
dim oWord
dim oFS
dim strDocDel

Function DocInit()
	set oWord=createobject("Word.Application")	
	Set oFS = CreateObject("Scripting.FileSystemObject")
	Randomize 
end Function

Function RandFile(strPath,strExp)
	strRrandFile=strPath&"\"&cint(10000*rnd)&cint(10000*rnd)&"."&strExp
	if	oFS.FileExists(strRrandFile) then
		RandFile=RandFile(strPath,strExp)
	else
		RandFile=strRrandFile
	end if	
end Function


Function DocRelease()
	oWord.ActiveDocument.Save()
    oWord.ActiveDocument.Close()
	oWord.Quit
	if	strDocDel<>"" then
		oFS.DeleteFile strDocDel
		DOCouttxt "del"&strDocDel
	end if
end Function


Function DocOutTxT(strTxT)
'	response.write strTxT
	msgbox  strTxT
End Function

Function DocOpen(strDocTemplet,strDocTo,bTemp)
	oFS.CopyFile strDocTemplet,strDocTo
	if bTemp then
		strDocDel=strDocTo
	end if
	DocoutTxt "open"&strDocTo
    oWord.Documents.Open(strDocTo)
end Function



Function GetVarFields()
   Dim i
    i = 0
    oWord.ActiveDocument.Content.Select
    While oWord.ActiveWindow.Selection.Find.Execute("=|*|=", True, True, True, , , , wdFindStop, False, "", False)
        ReDim Preserve VarField(i)
        strFound = oWord.ActiveWindow.Selection.Text
        VarField(i) = Replace(Replace(strFound, "=|", ""), "|=", "")
        i = i + 1
    Wend
	GetVarFields=VarField
End Function

Function GetFrom()
	dim i
	dim strForm
	dim VarFields
	strForm=""
	VarFields=GetVarFields()
	for i=0 to ubound(VarFields)
		strForm=strForm&"<tr><td>"&varFields(i)&"</td><td><input type=text name='"&varFields(i)&"'></td</tr>"
	next
	GetFrom=strForm
End Function


DocInit()
'strTempFile=RandFile(server.mappath("/DOCTEMPLET/TEMPFile"),"Doc")
strTempFile=RandFile("d:","Doc")
'DocOpen server.mappath("/DOCTEMPLET/_TEMPLET")&"\test.doc",strTempFile,True
'DocOpen "H:\test.doc",strTempFile,True
DocOpen "d:\test.doc",strTempFile,True
'GetFrom()
DocRelease()

'%>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -