how to disable output format option in sendobject command

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rahul2310
    New Member
    • Oct 2013
    • 62

    how to disable output format option in sendobject command

    i am mailing report in which all details are specified in body of mail, so do not require any attachment to go with that mail.
    So my question is how to disable or what to write in code to disable output format which is asked in
    Code:
    DoCmd.SendObject
  • zmbd
    Recognized Expert Moderator Expert
    • Mar 2012
    • 5501

    #2
    rahul2310:
    You will need to post the entire code you are using to send the email. It sounds as if you are attempting to use two different methods to send the email.

    Please format the vba script by selecting it and then clicking on the [CODE/] formating button.

    Comment

    • rahul2310
      New Member
      • Oct 2013
      • 62

      #3
      i am using simple code
      Code:
      DoCmd.SendObject acSendReport, "ConfirmationDateReminderReport", "Excel97-Excel2003Workbook(*.xls)", Me.Reporting_Authority_Email, Me.[HR_Representative_Name_Email], "", "CONFIRMATION REMINDER", "This is to inform you that " & Me.[Emp_Full_Name] & " is Due for confirmation on " & Me.Confirmation_Date & " .True, ""
      I do not requires output format which is excel in this case.
      If i leave it blank on button click it asks me for output format which i do not want
      thanks

      Comment

      • zmbd
        Recognized Expert Moderator Expert
        • Mar 2012
        • 5501

        #4
        First you need to understand the command you are using so: DoCmd.SendObjec t Method (Access) Office 2010

        It's importaint to understand what you are doing; however, if you just want a "fish" then goto the bottom of this post.

        However, IMHO, it's better to learn how to fish (^_^):

        Let's break down what you have:
        Code:
        DoCmd.SendObject _
           ObjectType:=acSendReport, _
           ObjectName:="ConfirmationDateReminderReport", _
           OutputFormat:="Excel97-Excel2003Workbook(*.xls)", _
           To:=Me.Reporting_Authority_Email, _
           Cc:=Me.[HR_Representative_Name_Email], _
           Bcc:="", _
           Subject:="CONFIRMATION REMINDER", _
           MessageText:="This is to inform you that " & Me.[Emp_Full_Name] & " is Due for confirmation on " & Me.Confirmation_Date & ".", _
           EditMessage:=True, _
           TemplateFile:=""
        Note that I am using the named Parameters ("ObjectType "), these are set using the ":=" symbols, and I've placed these on their own lines using the "_" continuation charactor. Using the named parameters in this case will make things easier to follow, fix, and modify.

        Errors as you have:
        - Your OutputFormat entry is invalid it needs to be one of the following (why they make this so difficult to find I don't know - but it is!):
        acFormatHTML: HTML format
        acFormatRTF: Rich text format (RTF)
        acFormatSNP: Access report snapshot
        acFormatTXT: Plain text
        acFormatXLS: Excel 2000-2003
        acFormatXLSB: Excel Binary Workbook (*.xlsb)
        acFormatXLSX: Excel Workbook (*.xlsx) Excel 2007/10
        acFormatXPS: XPS Format (*.xps) * XPS format
        acFormatPDF: PDF Format (*.pdf) * PDF report
        (note that snapshot may not available after ACC2010 and pdf is only available for 2007 w/service pack and for 2010 and newer) YOU MUST READ THE LINK TO THIS METHOD as there some limitations as to what and how things are transfered. ONLY the Snap, XPS, and PDF formats will preserve a report format as shown on the screen, also, memo fields are truncated at 255 charactors.

        - Second error was in your "MessaageTe xt" it is fixed above; you have: & " .True, ""
        you need: & ".", True, ""
        Personally, I would have built the string for the MessageText first and then placed the string in the function. As you have it now, if there are any errors, such as this, in either in the string or the function it will be difficult to fix/spot (this is petpeeve of mine that MS and others show to build the string within the function - PC's are fast, have tons of memory, and one line of code isn't going to slow the processor by so much as a 1/1000000 of a jiffy).

        Now that we have that cleared up, what I am reading is that you want to send an email only, no object?

        In that case, using the corrected code and my suggestion to build the message text string first:
        Code:
        '(...)
        Dim strMessage As String
        '(...)
        strMessage = "This is to inform you that " & _
           Me.[Emp_Full_Name] & _
           " is Due for confirmation on " & _
           Me.Confirmation_Date & "."
        '
        DoCmd.SendObject _
           ObjectType:=acSendNoObject, _
           To:=Me.Reporting_Authority_Email, _
           Cc:=Me.[HR_Representative_Name_Email], _
           Subject:="CONFIRMATION REMINDER", _
           MessageText:=strMessage, _
           EditMessage:=True
        Notice by using the named parameters, I don't have to have all those extra commas nor include anything that we're not using that is also optional! (^_^)
        This will Send out only the email message, no attachments.
        You will want to have an error trap here because if the user cancels the email, the email client will return an error and stall your script at that point.

        Just a suggestion for your posts:
        I understand that it is a fineline between too much and too little; however, posting your actual problem code to start with is usually the best practice along with at least the a description of what you want, what is happening, and what you've tried.

        (now I'm sure I've cross posted with someone; however, it takes time for me to re-read and spell check (^_^))
        Last edited by zmbd; Dec 24 '13, 02:52 PM.

        Comment

        • rahul2310
          New Member
          • Oct 2013
          • 62

          #5
          BEST it works like a champ
          thanks a lot zmbd

          Comment

          • zmbd
            Recognized Expert Moderator Expert
            • Mar 2012
            • 5501

            #6
            You're very welcome and you can call me "Z" (^_^)

            Comment

            Working...