Schedule with prompt don't run in BO XI3.1

Hello,

I try to schedule report with macro vba which filled automaticly prompt (begin and end dates)
and export the report in .txt file format which name contain the execution date .

The problem is that it work correctly in deski XI3.1 but when I tried to refresh the report within infoview, it dosen’t work properly.

First, the prompt does not filled in automaticly and the export files is not executed.
After, when I tried schedule without first part which is supposed to fill in audomaticly the prompt,
the exported run but the output file name doesn’t contain execution date.

The VBA’s code is here:

Dim BMname As String
Dim dtRun As String
Dim Outputdrive As String
Public Sub Document_BeforeRefresh(Cancel As Boolean)
   'dtRun = Now()
   dtRun = Format$(Now(), "yyyymmdd")
   Outputdrive = "\\APSPRODBIXI\bixi@bca\NTAG\Daily\"
   'Get report name
   BMname = ThisDocument.Name
   'create subdirectory
   On Error Resume Next
       MkDir Outputdrive
   On Error GoTo 0
   Rem Interactive = False
   'Application.Interactive = False
   Rem Create Date pour le Prompt et le rempli.
    ThisDocument.Variables("Date2").Value = Format(Now(), "DD/MM/YYYY")
    ThisDocument.Variables("Date2").Value = Weekday(ThisDocument.Variables("Date2").Value, vbMonday)
    If ThisDocument.Variables("Date2").Value = 1 Then
        ThisDocument.Variables("Date2").Value = Format(Now() - 3, "DD/MM/YYYY")
    Else
       ThisDocument.Variables("Date2").Value = Format(Now(), "DD/MM/YYYY")
    End If
    ThisDocument.Variables("Date1").Value = Format(Now() - 10, "DD/MM/YYYY")
    ThisDocument.Variables("Date1").Value = Weekday(ThisDocument.Variables("Date1").Value, vbMonday)
    If ThisDocument.Variables("Date1").Value = 7 Then
       ThisDocument.Variables("Date1").Value = Format(Now() - 12, "DD/MM/YYYY")
    Else
       If ThisDocument.Variables("Date1").Value = 1 Then
           ThisDocument.Variables("Date1").Value = Format(Now() - 10, "DD/MM/YYYY")
       Else
           If ThisDocument.Variables("Date1").Value = 6 Then
               ThisDocument.Variables("Date1").Value = Format(Now() - 11, "DD/MM/YYYY")
           Else
            ThisDocument.Variables("Date1").Value = Format(Now() - 10, "DD/MM/YYYY")
           End If
       End If
    End If
End Sub

Private Sub Document_AfterRefresh()
   'BMname = ThisDocument.Name
   'dtRun = Now()
   'dtRun = Format$(Now(), "yyyymmdd")
   'Outputdrive = "\\APSPRODBIXI\bixi@bca\NTAG\Daily\"
   ThisDocument.SaveAs (Outputdrive & BMname & "_" & dtRun & ".txt")
   'Application.Interactive = True
End Sub

Thank you for your help please… It’s urgent…

[Moderator Edit: Added code formatting - Andreas]


d_podjy :fr: (BOB member since 2010-05-12)

I believe after refresh is not supported when run server side on 3.1:-

Private Sub Document_AfterRefresh() 

Mak 1 :uk: (BOB member since 2005-01-06)

Hello Mak 1,

I confirm that AfterRefresh() sub work properly in XI3.1 because I have another report with vba’s code which use the AfterRefresh sub and the report schedule export properly the file.


d_podjy :fr: (BOB member since 2010-05-12)

I stand corrected :).
I know, for certain, the use of it server side is limited however. I believe this covers anything interactive, i.e. your prompts.

This post may help:-

https://bobj-board.org/t/53683


Mak 1 :uk: (BOB member since 2005-01-06)

I’ve got Application.Interactive=False on the vba code but it not work again in schedule.
So, I see the link but for me it is not the same problem because in mine, the macro’s don’t fill the prompt when I schedule the report.
But when I try to do export without the first part BeforeRefresh, the export is ok but date is missing in the file name.

For information: I use the same code with another report (on the AfterRefresh sub) which work properly.

Thanks.


d_podjy :fr: (BOB member since 2010-05-12)

From your first post:-

From your previous post:-

So are you trying tofill in the prompt with the macro, or not?
:?


Mak 1 :uk: (BOB member since 2005-01-06)

Hello Mark,

Excuse me for my late answer because I have no acces network lat week.

So, to ask for you question, yes, I’m tryed to fill the prompt with the vba’s macros and in deski, the macro fill properly the prompt but when I try with infoview or schedule, it does not the case…
So, I’m tried to to desactivate interactive but it not work again…

Thanks


d_podjy :fr: (BOB member since 2010-05-12)