+ Reply to Thread
Results 1 to 10 of 10

Obj Variable or with variable not set error on emailing diff jpg data to diff recipients

  1. #1
    Registered User
    Join Date
    02-01-2011
    Location
    California, Sacramento
    MS-Off Ver
    Excel 2010
    Posts
    92

    Obj Variable or with variable not set error on emailing diff jpg data to diff recipients

    I have used code from a couple different sources and have got it close but need a bit of help
    to finish it up.

    The code should create jpg images of the data and email one areas data to each recipient listed in
    a column.

    In the attached file I have two problems.
    Email with Image Attachment To Each Recipient v2 - Copy.xls

    1) When run, I get an Object variable or with variable not set error on the line:
    Please Login or Register  to view this content.
    If I uncomment
    Please Login or Register  to view this content.
    the code will run however it leads to my second problem:

    2) The code will create 5 emails for each recipient. Each recipient should only receive one email
    for their area in the order their email is listed and in the order the area is listed
    (e.g. email 1 to Area 1, email 2 to Area 2).

    As always, thank you for your invaluable assistance.

    Regards,

    BigDawg15

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Obj Variable or with variable not set error on emailing diff jpg data to diff recipien

    Hi Dawg,

    I don't use Outlook - but, can your post your code? I may be able to deduce the problem if I can see the code
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  3. #3
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Obj Variable or with variable not set error on emailing diff jpg data to diff recipien

    Hi, BigDawg15,

    The code will create 5 emails for each recipient.
    Thatīs what you coded when you loop through the address area as well as through the data areaa by
    Please Login or Register  to view this content.
    And I would expect these lines to be reversed:
    Please Login or Register  to view this content.
    as the With-Statement starts with no value for objMail.

    Besides I would recommend to use Late Binding as at least I no lomger want to have problems with broklen references while coding in 2007/2013 with an effective system in my company using 2010.

    @xladept:
    I wonder if you cared ro download the attachment to get a glimpse for the code.

    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  4. #4
    Registered User
    Join Date
    02-01-2011
    Location
    California, Sacramento
    MS-Off Ver
    Excel 2010
    Posts
    92

    Re: Obj Variable or with variable not set error on emailing diff jpg data to diff recipien

    @Holger

    I think some are reluctant to download files with good reason. I will work with the advice you have given and see what I can come up with.


    @xladept here ya go. thank you for looking.

    Please Login or Register  to view this content.
    Thank you both. I may be back.

    BigDawg15

  5. #5
    Registered User
    Join Date
    02-01-2011
    Location
    California, Sacramento
    MS-Off Ver
    Excel 2010
    Posts
    92

    Re: Obj Variable or with variable not set error on emailing diff jpg data to diff recipien

    Holger,

    And I would expect these lines to be reversed:

    With objMail
    Set objMail = objOutlook.CreateItem(0) '1 - Appointment 3 - Task

    as the With-Statement starts with no value for objMail.
    This fixed the first error.

    Thatīs what you coded when you loop through the address area as well as through the data areaa by

    For Each rngEntry In rngEntries

    For i = 1 To Application.WorksheetFunction.CountA(Range("D:D"))
    I understand this is where the second error is originating but unsure how to fix it.

    Thank you again for your patience and assistance.

    BigDawg15

  6. #6
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Obj Variable or with variable not set error on emailing diff jpg data to diff recipien

    Hi Dawg,

    I'm guessing that you should change the code to:

    Please Login or Register  to view this content.
    Last edited by xladept; 11-15-2014 at 04:37 PM. Reason: Just had duplicated Holger's post

  7. #7
    Registered User
    Join Date
    02-01-2011
    Location
    California, Sacramento
    MS-Off Ver
    Excel 2010
    Posts
    92

    Re: Obj Variable or with variable not set error on emailing diff jpg data to diff recipien

    xladept,

    Thank you for the edited code, however in the attachment in the OP it only sends the last set of data to
    all recipients.

    Not sure how to edit.

    Any more ideas?

    Holger?

    Thanks again,

    BigDawg15

  8. #8
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Obj Variable or with variable not set error on emailing diff jpg data to diff recipien

    Hi Dawg,

    I guess that I'll have to guess again!

  9. #9
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Obj Variable or with variable not set error on emailing diff jpg data to diff recipien

    Hi, BigDawg15,

    using a loop for the entries in Column D will always get the last area to be displayed as an image. You should refer to rngEntry instead and use that as a counter, please try
    Please Login or Register  to view this content.
    Ciao,
    Holger

  10. #10
    Registered User
    Join Date
    02-01-2011
    Location
    California, Sacramento
    MS-Off Ver
    Excel 2010
    Posts
    92

    Re: Obj Variable or with variable not set error on emailing diff jpg data to diff recipien

    @hladept

    Thanks for the effort. Your guess was better than mine.

    @Holger

    Thank you. Looks like you solved it.
    I appreciate your assistance and I understand the code
    a little more too.

    Regards,

    BigDawg15

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 6
    Last Post: 08-28-2014, 02:44 AM
  2. Replies: 0
    Last Post: 07-30-2013, 07:42 PM
  3. [SOLVED] Macro to send mail via lotus notes diff people diff attachment
    By mangeshp4 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-21-2013, 03:01 AM
  4. Replies: 2
    Last Post: 01-13-2013, 06:50 AM
  5. Replies: 0
    Last Post: 01-13-2005, 06:49 AM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1