Need help in exporting report to excel

Hi All

I am on Sage ERP Accpac 500 (Version 6.0A) and am trying to export report straight to excel without going thru the menu to select options, 

For some reason,  PDF works, 

rpt.NumOfCopies = 1
rpt.Destination = PD_FILE
rpt.Format = PF_PDF
rpt.PrintDir = "C:\tec2.pdf"
rpt.PrintReport

Exit Sub

but it did not work 

rpt.SetParam "INCLCHG", "3" ' Report parameter: 79
rpt.NumOfCopies = 1
rpt.Destination = PD_FILE
rpt.Format = PF_XLS
rpt.PrintDir = "C:\tec2.xls"
rpt.PrintReport

Exit Sub

ANy help would be great

  • 0
    Moving this post to the Sage 300 (formerly Sage Accpac) Support Group.

    Thanks,
    Derek
  • 0

    https://smist08.wordpress.com/2012/09/15/reporting-via-macros/

  • 0 in reply to 49153
    Hi. Checked the Smith's Blog. But unfortunately, the excel version of the codes is not working.....
  • 0
    Dear Darren,

    You can try to export the report after removing the “rpt.PrintDir“ line. So your code will be like this :-

    rpt.SetParam "INCLCHG", "3" ' Report parameter: 79
    rpt.NumOfCopies = 1
    rpt.Destination = PD_FILE
    rpt.Format = PF_XLS
    rpt.PrintReport

    In this case the report will get exported in the Sage USER folder under the Sage 300 installation path for e.g.
    “C:\Program Files\Sage\Sage 300 ERP\USER\ADMIN”.

    Hope this helps..

    Sincerely,
    Dinesh @greytrix
  • 0 in reply to Greytrix
    mmmm.,unfortunately no. It get back to the same old three dialog boxes of
    -file type
    -format option
    -saving location
    which I wanted to eliminate totally....

    Is there something in the text that make it different between PDF vs Xls ? As the former works...
  • 0 in reply to Darren_me
    Hi again, was talking to a friend and he said that it might be related to a "Conflict between" the report to be handled by AccpacCOMAPI against the final exported format of excel ?

    I include the full script as per below

    Dim mDBLinkCmpRW As AccpacCOMAPI.AccpacDBLink
    Set mDBLinkCmpRW = OpenDBLink(DBLINK_COMPANY, DBLINK_FLG_READWRITE)

    Dim mDBLinkSysRW As AccpacCOMAPI.AccpacDBLink
    Set mDBLinkSysRW = OpenDBLink(DBLINK_SYSTEM, DBLINK_FLG_READWRITE)

    Dim temp As Boolean
    Dim rpt As AccpacCOMAPI.AccpacReport
    Set rpt = ReportSelect("GLPTLS1", " ", " ")
    Dim rptPrintSetup As AccpacCOMAPI.AccpacPrintSetup
    Set rptPrintSetup = GetPrintSetup(" ", " ")
    rptPrintSetup.DeviceName = "TOSHIBA e2540cse on PJ-FS (redi"
    rptPrintSetup.OutputName = "TS085"
    rptPrintSetup.Orientation = 1
    rptPrintSetup.PaperSize = 9
    rptPrintSetup.PaperSource = 7
    rpt.PrinterSetup rptPrintSetup
    rpt.SetParam "SORTBY", "GLAMF.ACSEGVAL03" ' Report parameter: 6
    rpt.SetParam "ORDERBY", "GLAMF.ACSEGVAL03, GLAMF.ACCTSEGVAL, GLAMF.ABRKID, GLAMF.ACCTID" ' Report parameter: 11
    rpt.SetParam "RANGE", "Project\\Activity" ' Report parameter: 3
    rpt.SetParam "FROMACCT", "EE060101" ' Report parameter: 4
    rpt.SetParam "TOACCT", "EE060501" ' Report parameter: 5
    rpt.SetParam "FROMFMTACCT", "EE060101" ' Report parameter: 80
    rpt.SetParam "TOFMTACCT", "EE060501" ' Report parameter: 81
    rpt.SetParam "FRGRPID", " " ' Report parameter: 15
    rpt.SetParam "TOGRPID", "ZZZZZZZZZZZZ" ' Report parameter: 16
    rpt.SetParam "FRSORTID", " " ' Report parameter: 17
    rpt.SetParam "TOSORTID", "ZZZZZZZZZZZZ" ' Report parameter: 18
    rpt.SetParam "ACTGRPSB", "0" ' Report parameter: 14
    rpt.SetParam "INACTIVE", "N" ' Report parameter: 10
    rpt.SetParam "ACCTSEGTOT", "0" ' Report parameter: 50
    rpt.SetParam "FRPERD", "01" ' Report parameter: 8
    rpt.SetParam "TOPERD", "04" ' Report parameter: 9
    rpt.SetParam "FSYEAR", "2016" ' Report parameter: 7
    rpt.SetParam "CURRENCY", "F" ' Report parameter: 49
    rpt.SetParam "INCLQTY", "-1" ' Report parameter: 2
    rpt.SetParam "SEGNM1", "General Ledger Code" ' Report parameter: 19
    rpt.SetParam "SEGFR1", "5061" ' Report parameter: 20
    rpt.SetParam "SEGTO1", "6100" ' Report parameter: 21
    rpt.SetParam "USEGS", "0" ' Report parameter: 51
    rpt.SetParam "USER", "DARREN" ' Report parameter: 52
    rpt.SetParam "OPTIONALFIELDS", "-1" ' Report parameter: 53
    rpt.SetParam "SELOPTFLD1", " " ' Report parameter: 54
    rpt.SetParam "SELOPTFLD2", " " ' Report parameter: 55
    rpt.SetParam "SELOPTFLD3", " " ' Report parameter: 56
    rpt.SetParam "SELOPTTYPE1", "0" ' Report parameter: 57
    rpt.SetParam "SELOPTTYPE2", "0" ' Report parameter: 58
    rpt.SetParam "SELOPTTYPE3", "0" ' Report parameter: 59
    rpt.SetParam "SELOPTDEC1", "0" ' Report parameter: 60
    rpt.SetParam "SELOPTDEC2", "0" ' Report parameter: 61
    rpt.SetParam "SELOPTDEC3", "0" ' Report parameter: 62
    rpt.SetParam "SELOPTLEN1", "0" ' Report parameter: 75
    rpt.SetParam "SELOPTLEN2", "0" ' Report parameter: 76
    rpt.SetParam "SELOPTLEN3", "0" ' Report parameter: 77
    rpt.SetParam "SELOPTFRVAL1", " " ' Report parameter: 63
    rpt.SetParam "SELOPTFRVAL2", " " ' Report parameter: 65
    rpt.SetParam "SELOPTFRVAL3", " " ' Report parameter: 67
    rpt.SetParam "SELOPTTOVAL1", " " ' Report parameter: 64
    rpt.SetParam "SELOPTTOVAL2", " " ' Report parameter: 66
    rpt.SetParam "SELOPTTOVAL3", " " ' Report parameter: 68
    rpt.SetParam "SELOPTFRDISP1", " " ' Report parameter: 69
    rpt.SetParam "SELOPTFRDISP2", " " ' Report parameter: 71
    rpt.SetParam "SELOPTFRDISP3", " " ' Report parameter: 73
    rpt.SetParam "SELOPTTODISP1", " " ' Report parameter: 70
    rpt.SetParam "SELOPTTODISP2", " " ' Report parameter: 72
    rpt.SetParam "SELOPTTODISP3", " " ' Report parameter: 74
    rpt.SetParam "ROLLUPACCTS", "0" ' Report parameter: 78
    rpt.SetParam "SORTTRANS", "0" ' Report parameter: 82
    rpt.SetParam "INCLCHG", "3" ' Report parameter: 79
    rpt.NumOfCopies = 1
    rpt.Destination = PD_FILE
    rpt.Format = PF_XLS
    rpt.PrintDir = "C:\tec2.xls"
    rpt.PrintReport

    Exit Sub

    ACCPACErrorHandler:
    Dim lCount As Long
    Dim lIndex As Long

    If Errors Is Nothing Then
    MsgBox Err.Description
    Else
    lCount = Errors.Count

    If lCount = 0 Then
    MsgBox Err.Description
    Else
    For lIndex = 0 To lCount - 1
    MsgBox Errors.Item(lIndex)
    Next
    Errors.Clear
    End If
    Resume Next

    End If

    End Sub