|
还没解决?那我来帮你吧
很简单:objXL.Run "Macro1"就行了
原来那个QtoE如果数据多的话,导出会很慢,你试试下面这个吧,快些
Sub QueryToExcel(ByVal xlsName As String, ByVal strShtName As String, ByVal Hval As String)
'==============================================
'函数功能:将查询数据导出到Excel
'例子ueryToExcel "合医全部信息", "全部信息", "B4"
'xlsName=Excel文件名 "合医全部信息",
'strShtName=Excel工作簿名 "全部信息"
'Hval=从哪个单元格导出 "B4"
'===============================================
Dim objXL As Excel.Application
Dim objWs As Excel.Workbook
Dim obSTR As String
Set objXL = New Excel.Application
Set objWs = objXL.Workbooks.Open(CurrentProject.Path & "\" & xlsName & ".xls")
'=====================
'如果你想先运行Excel宏的话就加下面这句
'objXL.Run "Macro1"
'=====================
objWs.Worksheets(strShtName).Activate
objWs.Worksheets(strShtName).Range(Hval).CopyFromRecordset Me.导出参加信息子窗体.Form.Recordset '查询的子窗体记录
objXL.Visible = True '打开Excel表查看数据
Set objWs = Nothing
Set objXL = Nothing
End Sub |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?注册
x
|