Skip to main content
Announcements
SYSTEM MAINTENANCE: Thurs., Sept. 19, 1 AM ET, Platform will be unavailable for approx. 60 minutes.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Macro not working this week?


Hi,

I have macro in straight table which will send excel file to user mail. Last week it works fine. But this week when I tried run macro it is

showing

Object required: 'obj'

Can anyone please suggest me how can I set this.

Thanks.

7 Replies
Not applicable
Author

This is the macro which is in straight table.

function MailReport()
    Dim objEmail
    Const cdoSendUsingPort = 2     ' Send the message using SMTP
    Const cdoAnonymous = 0     'Do not authenticate
    Const cdoBasic = 1         'basic (clear-text) authentication
    Const cdoNTLM = 2         'NTLM
    SMTPServer = "XX.com"
    Const SMTPPort = 21                 ' Port number for SMTP
    Const SMTPTimeout = 70              ' Timeout for SMTP in seconds
    rem ** let QV sleep for 10 seconds **
    ActiveDocument.GetApplication.Sleep 10000
    Set objEmail = CreateObject("CDO.Message")
    Set objConf = objEmail.Configuration
    Set objFlds = objConf.Fields
    set obj = ActiveDocument.GetSheetObject("CH04")
    set v = ActiveDocument.Variables("vStartDate")
    v.SetContent vMacroVariable, true
With objFlds
        '---------------------------------------------------------------------
           ' SMTP server details
           .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = cdoSendUsingPort 'ok
           .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = SMTPServer      'ok
           .Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoBasic  'ok
          
           .Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "xxxyyy"
           .Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "password"         
             .Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = SMTPPort
           .Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False
           .Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = SMTPTimeout
           .Update
        '---------------------------------------------------------------------
    End With


    objEmail.To = "XX@mail.com"        'Email Recipient
    objEmail.CC = "YY@mail.com"
    objEmail.From = "Mail"                        'Email Sender
    objEmail.Subject = "Dashboard"                        ' Subject
    objEmail.TextBody = "Email"     'Text Body
    obj.ExportBiff "D:\Report.xls" 
    objEmail.AddAttachment  "D:\Report.xls"

    objEmail.Send
    Set objFlds = Nothing
    Set objConf = Nothing
    Set objEmail = Nothing
    end function

ThornOfCrowns
Specialist II
Specialist II

You might need to post the code to see where it's going wrong.

SergeyMak
Partner Ambassador
Partner Ambassador

Hi

To be sure that the problem in this week, just try to change date on the PC.

then please post code here.

Regards

Regards,
Sergey
Not applicable
Author

Thanks. I posted the code. It is under currently moderating...

Not applicable
Author

Please can you have a look on the code and suggest me how to set this.

Not applicable
Author

Any solution please?

ThornOfCrowns
Specialist II
Specialist II

set obj = ActiveDocument.GetSheetObject("CH04")

Does this Chart exist in the document you're running the macro on? That's the only reference to 'obj' in the code. Comment that line out and see what happens.