Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2013
    Posts
    2

    Unanswered: Again a topic about export to excel

    Hello there,

    Don't pick on me because of the fact there a another 1.793.373 topics about this. I read a lot of topics and website but I can't get it to work.

    I have a button on my main formular, which called "Export". When clicked on the button there should be 6 query's exported to separate excel files.

    I build the macro mentioned beneath macro and give the action to the button to run this macro when clicked. Sadly, nothing works Could you help guys?

    Btw is there any possibility when the queries are extracted to excel, that the separate files are e-mailed automatically to different e-mail addresses?

    Thank you in advance

    Private Sub Export_Click()

    DoCmd.OutputTo acOutputQuery, "bla NL04", acFormatXLS, "D:\Reports\NL04" & Format(Date, "yyyymmdd") & ".xls"
    DoCmd.OutputTo acOutputQuery, "bla NL05", acFormatXLS, "D:\Reports\NL05" & Format(Date, "yyyymmdd") & ".xls"
    DoCmd.OutputTo acOutputQuery, "bla NL07", acFormatXLS, "D:\Reports\NL07" & Format(Date, "yyyymmdd") & ".xls"
    DoCmd.OutputTo acOutputQuery, "bla NL09", acFormatXLS, "D:\Reports\NL09" & Format(Date, "yyyymmdd") & ".xls"



    End Sub

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    instead of date try date(). it shouldn't matter
    you may need to enclose the query name in square brackets
    Code:
    DoCmd.OutputTo acOutputQuery, "[bla NL04]", acFormatXLS, "D:\Reports\NL04" & Format(Date(), "yyyymmdd") & ".xls"
    if you run the query does it retrieve records

    as to further help dunno, I don't use macros (unless I have to) because they are a PITA and can be tricky to debug

    if you want to send the excel files as an attachment, then Im sure it can be done, just not somethign Ive doen recently. try searching here and on google of rms access email attachements
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Mar 2013
    Posts
    2
    I now constructed this and this works for me

    Sub exportmacro()

    DoCmd.OutputTo acOutputQuery, "blaNL04", acFormatXLS, "D:\Reports\NL04" & Format(Date, "yyyymmdd") & ".xls"
    DoCmd.OutputTo acOutputQuery, "blaNL05", acFormatXLS, "D:\Reports\NL05" & Format(Date, "yyyymmdd") & ".xls"
    DoCmd.OutputTo acOutputQuery, "bla NL07", acFormatXLS, "D:\Reports\NL07" & Format(Date, "yyyymmdd") & ".xls"
    DoCmd.OutputTo acOutputQuery, "blaNL09", acFormatXLS, "D:\Reports\NL09" & Format(Date, "yyyymmdd") & ".xls"

    End Sub
    In the future I want to add an extra worksheet to this files and e-mail them to specific e-mail addresses. I found some code but I really don't understand it. Is there someone here whom wants to help me with this one?

    Thank you

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •