Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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.
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
You might need to post the code to see where it's going wrong.
Hi
To be sure that the problem in this week, just try to change date on the PC.
then please post code here.
Regards
Thanks. I posted the code. It is under currently moderating...
Please can you have a look on the code and suggest me how to set this.
Any solution please?
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.