I've create this simple script (file name test.vbs), I use it for scheduling a little job:
dim accessApp
set accessApp = createObject("Access.Application")
accessApp.OpenCurrentDataBase("D:\Files\Galileo\SF Mail.mdb")
accessApp.Run "MailOrdiniAgente"
accessApp.Quit
set accessApp = nothing
And I've created this Access module (saved into SFMail.mdb, module name MailOrdiniAgente )
Private Sub MailOrdiniAgente()
On Error GoTo Err_MailOrdiniAgente
Dim stDocName As String
Dim FileName, Check As String
Dim vMailA As String
Dim rs, ra As DAO.Recordset
Set rs = CurrentDb.OpenRecordset("Tabella agenti", dbOpenDynaset)
If rs.EOF Then
GoTo Exit_MailOrdiniAgente
End If
rs.MoveFirst
Do Until rs.EOF
FileName = Replace(rs.Fields("CODICE"), " ", "")
Check = rs.Fields("INVIOMAIL")
vMailA = rs.Fields("MAIL")
If Check = "Vero" Then
DoCmd.RunMacro "Macro eliminazione filtro agente"
Set ra = CurrentDb.OpenRecordset("Tabella filtro agente", dbOpenDynaset)
ra.AddNew
ra.Fields("AGENTE") = FileName
ra.Update
DoCmd.RunMacro "Macro SapSF"
DoCmd.OutputTo acOutputReport, "Report agente ordini aperti", acFormatPDF, "C:\Temp\Agente" & FileName & ".pdf"
ra.Close
End If
rs.MoveNext
Loop
rs.Close
Set rs = Nothing
Exit_MailOrdiniAgente:
Exit Sub
Err_MailOrdiniAgente:
MsgBox Err.Description
Resume Exit_MailOrdiniAgente
End Sub
Problem running this script:
Windows Script Host... impossible find routine 'MailOrdiniAgente' error code 800A09D5
I'm not a great programmer, so probably I wrong something on creating the module or into the code of the same module that I've posted on top... I'm useing access 2007
Thanks a lot for help or advice me!
dim accessApp
set accessApp = createObject("Access.Application")
accessApp.OpenCurrentDataBase("D:\Files\Galileo\SF Mail.mdb")
accessApp.Run "MailOrdiniAgente"
accessApp.Quit
set accessApp = nothing
And I've created this Access module (saved into SFMail.mdb, module name MailOrdiniAgente )
Private Sub MailOrdiniAgente()
On Error GoTo Err_MailOrdiniAgente
Dim stDocName As String
Dim FileName, Check As String
Dim vMailA As String
Dim rs, ra As DAO.Recordset
Set rs = CurrentDb.OpenRecordset("Tabella agenti", dbOpenDynaset)
If rs.EOF Then
GoTo Exit_MailOrdiniAgente
End If
rs.MoveFirst
Do Until rs.EOF
FileName = Replace(rs.Fields("CODICE"), " ", "")
Check = rs.Fields("INVIOMAIL")
vMailA = rs.Fields("MAIL")
If Check = "Vero" Then
DoCmd.RunMacro "Macro eliminazione filtro agente"
Set ra = CurrentDb.OpenRecordset("Tabella filtro agente", dbOpenDynaset)
ra.AddNew
ra.Fields("AGENTE") = FileName
ra.Update
DoCmd.RunMacro "Macro SapSF"
DoCmd.OutputTo acOutputReport, "Report agente ordini aperti", acFormatPDF, "C:\Temp\Agente" & FileName & ".pdf"
ra.Close
End If
rs.MoveNext
Loop
rs.Close
Set rs = Nothing
Exit_MailOrdiniAgente:
Exit Sub
Err_MailOrdiniAgente:
MsgBox Err.Description
Resume Exit_MailOrdiniAgente
End Sub
Problem running this script:
Windows Script Host... impossible find routine 'MailOrdiniAgente' error code 800A09D5
I'm not a great programmer, so probably I wrong something on creating the module or into the code of the same module that I've posted on top... I'm useing access 2007
Thanks a lot for help or advice me!