Report print Macros

i have the below Exception please any help ????   

  • 0

    I always delete that line, it's not needed.

  • 0 in reply to Jay Converse Acumen

     the problem appear in another place after delete it

  • 0 in reply to shadyshady

    Re-record it, you're missing some code.

  • 0 in reply to Jay Converse Acumen

    this is the whole Code there is nothing missing

    'Reference to Accpac.Advantage.dll required

           'To look for unprinted invoices and print them.

           Dim mSession As New AccpacCOMAPI.AccpacSession 'declare a session

           mSession.Init("", "CS", "CS0000", "56A") 'init the session

           mSession.Open("ADMIN", "ADMIN", "CYBDAP", DateTime.Today, 0, "") 'open the session with appropriate credentials

           Dim mDBLinkCmpRW As AccpacCOMAPI.AccpacDBLink

           Dim mDBLinkSysRW As AccpacCOMAPI.AccpacDBLink

           mDBLinkCmpRW = mSession.OpenDBLink(AccpacCOMAPI.tagDBLinkTypeEnum.DBLINK_COMPANY, AccpacCOMAPI.tagDBLinkFlagsEnum.DBLINK_FLG_READWRITE)

           mDBLinkSysRW = mSession.OpenDBLink(AccpacCOMAPI.tagDBLinkTypeEnum.DBLINK_SYSTEM, AccpacCOMAPI.tagDBLinkFlagsEnum.DBLINK_FLG_READWRITE)

           Dim temp As Boolean

           Dim rpt As AccpacCOMAPI.AccpacReport

           rpt = mSession.ReportSelect("OEINV01[C:\SAGE300\OE61A\ENG\OEINV01.RPT]", "      ", "      ")

           Dim rptPrintSetup As AccpacCOMAPI.AccpacPrintSetup

           'rptPrintSetup = mSession.GetPrintSetup(" ", " ")

           'rptPrintSetup.DeviceName = "Microsoft XPS Document Writer"

           'rptPrintSetup.OutputName = "XPSPort:"

           'rptPrintSetup.Orientation = 10

           'rptPrintSetup.PaperSize = 9

           'rptPrintSetup.PaperSource = 15

           'rpt.PrinterSetup(rptPrintSetup)

           rpt.SetParam("PRINTED", "1")              ' Report parameter: 4

           rpt.SetParam("DELMETHOD", "1")            ' Report parameter: 6

           rpt.SetParam("ECENABLED", "0")            ' Report parameter: 7

           rpt.SetParam("DIRECTEC", "0")             ' Report parameter: 8

           rpt.SetParam("QTYDEC", "0")               ' Report parameter: 5 - O/E Sales History:Detail,Sort by Item Number

           rpt.SetParam("BOITEM", "1")               ' Report parameter: 9

           rpt.SetParam("SORTFROM", "IN0000002")     ' Report parameter: 2

           rpt.SetParam("SORTTO", "IN0000002")       ' Report parameter: 3

           rpt.SetParam("SWDELMETHOD", "3")          ' Report parameter: 10

           rpt.SetParam("SERIALLOTNUMBERS", "0")     ' Report parameter: 14

           rpt.SetParam("PRINTKIT", "0")             ' Report parameter: 11

           rpt.SetParam("PRINTBOM", "0")             ' Report parameter: 12

           rpt.SetParam("RETAINAGE", "0")            ' Report parameter: 13

           rpt.SetParam("@SELECTION_CRITERIA", "(({OEINVH.INVNUMBER} >= ""IN0000002"") AND ({OEINVH.INVNUMBER} <= ""IN0000002""))")   ' Report parameter: 0

           rpt.SetParam("PRINTED", "1")              ' Report parameter: 4

           rpt.SetParam("DELMETHOD", "1")            ' Report parameter: 6

           rpt.SetParam("ECENABLED", "0")            ' Report parameter: 7

           rpt.SetParam("DIRECTEC", "0")             ' Report parameter: 8

           rpt.SetParam("QTYDEC", "0")               ' Report parameter: 5 - O/E Sales History:Detail,Sort by Item Number

           rpt.SetParam("BOITEM", "1")               ' Report parameter: 9

           rpt.SetParam("SORTFROM", "IN0000002")     ' Report parameter: 2

           rpt.SetParam("SORTTO", "IN0000002")       ' Report parameter: 3

           rpt.SetParam("SWDELMETHOD", "1")          ' Report parameter: 10

           rpt.SetParam("SERIALLOTNUMBERS", "0")     ' Report parameter: 14

           rpt.SetParam("PRINTKIT", "0")             ' Report parameter: 11

           rpt.SetParam("PRINTBOM", "0")             ' Report parameter: 12

           rpt.SetParam("RETAINAGE", "0")            ' Report parameter: 13

           rpt.SetParam("EMAILSENDTO", "[email protected]")   ' Report parameter: 0

           rpt.SetParam("EMAILSUBJECT", "CYBERIA - Middle East Internet Company Ltd. Invoice")   ' Report parameter: 0

           rpt.SetParam("EMAILTEXT", "Dear :\0D\0A\0D\0ATo view and print the attached invoice, double-click on the invoice icon, and then choose File, Print when the invoice is displayed. To save the invoice, copy it from this e-mail to another folder on your computer.\0D\0A\0D\0AIf you have any questions regarding this invoice, please contact me at .\0D\0A\0D\0ANote:  You require Adobe Acrobat Reader to view this attachment. Adobe Acrobat Reader is available from www.adobe.com \0D\0A\0D\0ARegards,\0D\0A\0D\0AMajdi Abdul Qader")   ' Report parameter: 0

           rpt.SetParam("@SELECTION_CRITERIA", "{OEINVH.INVNUMBER} = ""IN0000002""")   ' Report parameter: 0

           rpt.NumOfCopies = 1

           rpt.Destination = tagPrintDestinationEnum.PD_PREVIEW

           rpt.PrintDir = "C:\sage300DATA\USER\ADMIN"

           rpt.PrintReport()

           rpt.SetParam("PRINTED", "1")              ' Report parameter: 4

           rpt.SetParam("DELMETHOD", "1")            ' Report parameter: 6

           rpt.SetParam("ECENABLED", "0")            ' Report parameter: 7

           rpt.SetParam("DIRECTEC", "0")             ' Report parameter: 8

           rpt.SetParam("QTYDEC", "0")               ' Report parameter: 5 - O/E Sales History:Detail,Sort by Item Number

           rpt.SetParam("BOITEM", "1")               ' Report parameter: 9

           rpt.SetParam("SORTFROM", "IN0000002")     ' Report parameter: 2

           rpt.SetParam("SORTTO", "IN0000002")       ' Report parameter: 3

           rpt.SetParam("SWDELMETHOD", "2")          ' Report parameter: 10

           rpt.SetParam("SERIALLOTNUMBERS", "0")     ' Report parameter: 14

           rpt.SetParam("PRINTKIT", "0")             ' Report parameter: 11

           rpt.SetParam("PRINTBOM", "0")             ' Report parameter: 12

           rpt.SetParam("RETAINAGE", "0")            ' Report parameter: 13

           rpt.SetParam("@SELECTION_CRITERIA", "(({OEINVH.INVNUMBER} >= ""IN0000002"") AND ({OEINVH.INVNUMBER} <= ""IN0000002"")) AND ({ARCUS.DELMETHOD} = 0)")   ' Report parameter: 0

  • 0 in reply to shadyshady

    That is NOT from a recorded macro.  And when you put it into VBA and fix the syntax errors, it works fine.

  • 0 in reply to Jay Converse Acumen

    i cant understand you jay i make record then nothing changed only the session created

  • 0 in reply to shadyshady

    Why did you add a session?  That's not required, you just run the macro in the company you want.

  • 0 in reply to shadyshady

    How to do this i need session to open dblink to company please help me how to do this without session

  • 0 in reply to shadyshady

    because ReportSelect,GetPrintSetup methods need sessions if i write like this give me error

    rpt = ReportSelect("OEINV01[C:\SAGE300\OE61A\ENG\OEINV01.RPT]", "      ", "      ")

    Dim rptPrintSetup As AccpacCOMAPI.AccpacPrintSetup

    ptPrintSetup = GetPrintSetup(" ", " ")

  • 0 in reply to shadyshady

    Simply login to the different company, and run the macro.

  • 0 in reply to shadyshady

    anybody can help me please???

  • 0 in reply to shadyshady

    I already told you.  You don't need to add a session!  Just login to the other company, and run the macro there.

  • 0 in reply to Jay Converse Acumen

    i told you i cant understand you

    my issue is to print the report in VS 2008 and there exceptions

    why you told me to login to other company ???

  • 0 in reply to shadyshady

    Why VS2008?  VBA is much simpler.  

  • 0
    Hi, I have agonized over the very same problem. I have found that you need to run your App in 32 bit mode, not 64. Go to Project, Properties, Compile tab. Select 'Advanced Compile Options', then set Target CPU to 'x86'. Let me know if this helps, everyone here seems to want to run macros from within Sage VBA :)
  • 0 in reply to jmoser
    This is the Macros folder after all.... macros run in VBA.
  • 0 in reply to 49153
    Macro is a misnomer. These are 32 bit COM API objects which can be hosted in VBA, but the intent is clearly an API. One can make interesting persuasive applications which consume the API, and this is what gives them their value. Granted VBA gives a happy path, but applications are limited.