Db-why-not
Registered User.
- Local time
- Today, 10:57
- Joined
- Sep 17, 2019
- Messages
- 160
I created a form with a button that automatically exports several querys into an excel file with each query being 1 sheet in the excel file. I want to automatically have the excel file with a password. How to I add code that would do that? I would I integrate code that would do that into my existing code?
See my existing code
Any help would be appreciated. Thank you.
See my existing code
Code:
Private Sub CommandTransfer_Click()
On Error GoTo SubError
strPath = "M:\Research\Lung Us\Data\Exporting_OHSU\OHSU BAMC Lung Point Clinical Database _" & "_" & Format(Date(),"yyyy_mm_dd") & ".xlsx"
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12Xml, "OHSU_Demographics", strPath
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12Xml, "OHSU_Admission_dx", strPath
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12Xml, "OHSU_pre_existing", strPath
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12Xml, "OHSU_Qualifying_cond", strPath
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12Xml, "OHSU_New_Pulm", strPath
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12Xml, "OHSU_US_scans", strPath
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12Xml, "OHSU_CXR_CT", strPath
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12Xml, "OHSU_Micro", strPath
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12Xml, "OHSU_DC_DX", strPath
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12Xml, "OHSU_US_Review", strPath
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12Xml, "OHSU_Box_Uploads", strPath
MsgBox "File Exported successfully", vbInformation + vbOKOnly, "Export Success"
SubExit:
Exit Sub
SubError:
MsgBox "Error Number: " & Err.Number & "= " & Err.Description, vbCritical + vbOKOnly, "An error occured"
GoTo SubExit
End Sub
Any help would be appreciated. Thank you.