Results 1 to 11 of 11
  1. #1
    3 Star Lounger
    Join Date
    Jul 2001
    Posts
    280
    Thanks
    0
    Thanked 0 Times in 0 Posts

    convert report into word document (Access 2000)

    How can i convert the results of a report into a word ? Ususally, after i open a report,i have a buton on the toolbar, named Publish with MS word, i press it, and the
    report is obtained as a word in MyDocuments file.Can i do exactly the same action with the help of a code? I want to do it by pressing a button in the form.My report is called rptIssues and i open it with a button from a form. If i have the email address of the recipient, can i send this report directly to him??
    I mean the contents of the report in a Word form, send as an attachment in an email? It seems to me a formidable task, to convert a report, and then send it just with a click

  2. #2
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: convert report into word document (Access 2000)

    Here a quick and dirty code sample. Put this code in the on click event of your button.

    Dim myOLApp As New Outlook.Application
    Dim myOLItem As Outlook.MailItem
    DoCmd.OpenReport "rptIssues", acViewPreview
    DoCmd.RunCommand acCmdOutputToRTF
    Set myOLItem = myOLApp.CreateItem(olMailItem)
    myOLItem.To = "Somebody@SomeWhere.com"
    myOLItem.Subject = "Report"
    myOLItem.Body = "Please find in attachment the report for...."
    myOLItem.Attachments.Add ""Cocuments and settingsUserNameMy DocumentsrptIssues.rtf"
    myOLItem.Display

    Adjust myOLItem.To, myOLItem.Subject, myOLItem.Body and myOLItem.Attachments.Add to your settings.
    If you want to send the report without opening it replace the line :
    myOLItem.Display
    by
    myOLItem.Send

    To run this code you must have a reference to Outlook.
    In the VBE editor, select Tools / References and check Microsoft Outlook 9.0 Object Library
    Francois

  3. #3
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: convert report into word document (Access 2000)

    Addition :
    If you don't want to preview the report and don't want opening Word, replace the two lines :
    DoCmd.OpenReport "rptIssues", acViewPreview
    DoCmd.RunCommand acCmdOutputToRTF
    by
    DoCmd.OutputTo acOutputReport, "rptIssues", acFormatRTF, _
    "Cocuments and settingsUserNameMy DocumentsrptIssues.rtf"
    Francois

  4. #4
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,624
    Thanks
    3
    Thanked 60 Times in 60 Posts

    Re: convert report into word document (Access 2000)

    In addition to the excellent advise from others, I should point out that the "Publish to MS Word" button actually converts your Access report to RTF, which does a pretty poor job of simulating what the Access report looked like if the report is anything other than simple. For example, if you have columnar data, it uses tabs to try to make the columns, and often the data won't line up. Also any graphic elements such as lines and borders will be lost. Just an FYI. If of course you are emailing the report, it may not matter.
    Wendell

  5. #5
    3 Star Lounger
    Join Date
    Jul 2001
    Posts
    280
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: convert report into word document (Access 2000)

    Thank you for your excellent advice indeed. It works as you have shown.The problem with me is that report is in cyrillic and when the code converts the report into a word document
    in MyDocuments, it is unredable. Interesting is that when i usse the toolbar, then the word document is ok. I supose it is the RTF format and my question is is there ay wat to avoid that?
    Actually the report must be sent as an attachment. Can i use some other format in the code ?

    Best regards

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: convert report into word document (Access 2000)

    Have you tried using DoCmd.SendObject? I have no idea how it will treat reports with Cyrillic text. Example:

    DoCmd.SendObject acSendReport, "NameOfReport", acFormatRTF, "Somebody@SomeWhere.com", , , "Test mail", "Please see the attached report.", True

  7. #7
    3 Star Lounger
    Join Date
    Jul 2001
    Posts
    280
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: convert report into word document (Access 2000)

    Thank you very much for your advices.They are wonderful,all of them, and I regret i meet some problems due to the cyrillic and not to the codes.
    I would like to restrict my question as to the converting the report into a word document in My Documents file.
    Could you please let me know is there any other way in which to place the report into a word document in My Documents file and not sending it to email? I can convert easily the report if i use the toolabr button Publish to MS word and then the word document is readable.But is it
    possible to imitate what this toolbar button is doing and recevie the same result in the report?
    I cannot explain myself why it is happening with the code and not with the toolbar button.
    best regards

  8. #8
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: convert report into word document (Access 2000)

    In theory, the VBA commands DoCmd.OutputTo and RunCommand acCmdOutputToRTF should do the same as the toolbar button. I'm afraid I don't know why they act differently for Cyrillic characters, and I can't test this myself.

  9. #9
    3 Star Lounger
    Join Date
    Jul 2001
    Posts
    280
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: convert report into word document (Access 2000)

    Dear Hans,

    Thank you very much for your kind attention.Of course you are right.As always. I have found a way to solve my problem by
    importing a special font called bulcourir.When the word document appears in the MyDocuments file,
    i open it then i "select all" and choose the font,and then my text appears!
    How can i make the font bulcourir be my on default font in order to avoid the manual selection ?

  10. #10
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: convert report into word document (Access 2000)

    If you modify your report to use the bulcourir font for all labels, text boxes etc., the exported RTF document will use bulcourir too.

  11. #11
    3 Star Lounger
    Join Date
    Jul 2001
    Posts
    280
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: convert report into word document (Access 2000)

    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
  •