I am a new bee to VBA. I have created an app which outputs the data from access to an Excel spread sheet and saves it. I have used the following snippet to perform that action. The following is the code that I have used, and it works fine. However, I have 2 questions
1. A security alert opens up every time I try to write in to the access database. How do I avoid that?
2. The "query1" in the following code is a stored proc in access, which requires a parameter (projnumber). Currently I have to manually type this projecId to pass it to the stored proc. How do I do it programatically ?
>>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>>>>>>>>>>>
Dim strOutputPath As String
Set a = CreateObject("a ccess.applicati on")
a.OpenCurrentDa tabase ("W:\Quality Assurance\QA document automation\Data base\Automation Documentation.m db")
'a.DoCmd.OpenQu ery "Query1"
DoCmd.TransferS preadsheet acExport, acSpreadsheetTy peExcel3, "query1", "W:\Quality Assurance\QA document automation\Temp late\TestCaseMa nagement.xls", False
'a.DoCmd.Close
'a.Quit
Application.Wor kbooks.Open ("W:\Quality Assurance\QA document automation\Temp late\TestCaseMa nagement.xls")
Application.Vis ible = False
With Workbooks("Test CaseManagement. xls")
.SaveAs ("W:\Quality Assurance\QA document automation\Test cases\" & projnumber & ".xls")
End With
ThisWorkbook.Cl ose (False)
1. A security alert opens up every time I try to write in to the access database. How do I avoid that?
2. The "query1" in the following code is a stored proc in access, which requires a parameter (projnumber). Currently I have to manually type this projecId to pass it to the stored proc. How do I do it programatically ?
>>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>>>>>>>>>>>
Dim strOutputPath As String
Set a = CreateObject("a ccess.applicati on")
a.OpenCurrentDa tabase ("W:\Quality Assurance\QA document automation\Data base\Automation Documentation.m db")
'a.DoCmd.OpenQu ery "Query1"
DoCmd.TransferS preadsheet acExport, acSpreadsheetTy peExcel3, "query1", "W:\Quality Assurance\QA document automation\Temp late\TestCaseMa nagement.xls", False
'a.DoCmd.Close
'a.Quit
Application.Wor kbooks.Open ("W:\Quality Assurance\QA document automation\Temp late\TestCaseMa nagement.xls")
Application.Vis ible = False
With Workbooks("Test CaseManagement. xls")
.SaveAs ("W:\Quality Assurance\QA document automation\Test cases\" & projnumber & ".xls")
End With
ThisWorkbook.Cl ose (False)
Comment