I am trying to convert some of my VB6 apps over to RBasic. These are small “automation” VB apps that open a MS Access database, run a macro in it and then close it.
Here is the code of one of them…
Sub Main()
'To open ms access and run a macro
'Used on the server to replace the batch file named CSCWeekly.bat
'
'Created Oct 20, 2010 - Rick Yerex
' Winserver 2008 & Task Scheduler seem to have problems running batch files
'
Dim strDB As String
Dim strMac As String
'strDB = "C:\\ipcc\\eomreports\\eomreporting.mdb"
'strMac = "mTEST"
strDB = "E:\\ReportFiles\\Report_KBIS2012.mdb"
strMac = "mPrintCSCWeeklyAuto"
RunAccessMacro strDB, strMac, , True
End Sub
Private Sub RunAccessMacro(ByVal strDB As String, ByVal strMacro As String, _
Optional lngRunX As Long = 1, _
Optional CloseOnComplete As Boolean = True)
On Error GoTo Hell
'Create a Access object
Dim objAccess As Access.Application
Set objAccess = New Access.Application
'Open the database and run the macro
With objAccess
.OpenCurrentDatabase strDB
.DoCmd.RunMacro strMacro, lngRunX
'Close the Database
If CloseOnComplete Then .CloseCurrentDatabase
End With
Set objAccess = Nothing
Exit_For:
On Error GoTo 0
Exit Sub
Hell:
MsgBox "sum ting wong"
GoTo Exit_For
End Sub
I can’t seem to figgure out how to accomplish this in RBasic. Can anyone assist pls?