我用谷歌搜索没有太多运气。基本上每次创建一个 excel 电子表格(基于模板),都需要密码保护。这可以做到吗?
'______________________CreateExcel()____________________________________
Function CreateExcel()
SELECT DATA FROM SQL TABLE
If objStructure.BOF = False And objStructure.EOF = False Then
Do While objStructure.EOF = False
Call CreateActualExcel()
objRsExcel.Fields("Field") = objStructure.Fields("Field")
objStructure.MoveNext
Loop
End If
End Function
'......................End CreateExcel()..................................
'______________________CreateActualExcel()________________________________
Sub CreateActualExcel()
Dim objSFSO
Dim strCon, strSQL
strFile = " Staffing_List_" & Clng(Timer()) & ".xls"
Set objSFSO = CreateObject("Scripting.FileSystemObject")
objSFSO.CopyFile conFolder & conTemplate, conFolder & strFile
Set objSFSO = Nothing
Set objRsExcel = CreateObject("ADODB.RecordSet")
strCon = _
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
conFolder & strFile & ";" & _
"Extended Properties=""Excel 8.0;HDR=Yes;maxscanrows=1;"";"
strSQL = "Select * From [Sheet1$]"
objRsExcel.Open strSql, strCon, 3, 2
End Sub
'......................End CreateActualExcel()............................
提前感谢您的帮助。
克莱尔:-)