Results 1 to 20 of 20

VBA stopped with Error-Message

Threaded View

torti111 VBA stopped with Error-Message 04-26-2016, 04:41 AM
romperstomper Re: problem with code 04-26-2016, 05:27 AM
torti111 Re: problem with code 04-26-2016, 05:43 AM
romperstomper Re: problem with code 04-26-2016, 06:00 AM
torti111 Re: problem with code 04-26-2016, 06:11 AM
romperstomper Re: problem with code 04-26-2016, 06:19 AM
torti111 Re: problem with code 04-26-2016, 06:34 AM
romperstomper Re: problem with code 04-26-2016, 06:47 AM
torti111 Re: problem with code 04-26-2016, 07:33 AM
protonLeah Re: problem with code 04-26-2016, 11:48 PM
torti111 Re: problem with code 04-27-2016, 02:33 AM
FDibbins Re: the following code works... 04-27-2016, 10:57 AM
romperstomper Re: the following code works... 04-27-2016, 06:03 PM
torti111 Re: VBA stopped with... 05-02-2016, 09:33 AM
romperstomper Re: VBA stopped with... 05-02-2016, 11:40 AM
torti111 Re: VBA stopped with... 05-03-2016, 02:43 AM
romperstomper Re: VBA stopped with... 05-03-2016, 04:43 AM
torti111 Re: VBA stopped with... 05-03-2016, 05:38 AM
romperstomper Re: VBA stopped with... 05-03-2016, 05:47 AM
torti111 Re: VBA stopped with... 05-03-2016, 06:37 AM
  1. #1
    Registered User
    Join Date
    08-27-2015
    Location
    Friedberg
    MS-Off Ver
    2010
    Posts
    68

    VBA stopped with Error-Message

    Hi all,

    I have the following VBA Code and an Excel file from which the VBA get his data (25 lines).
    My Problem is, that I do not have an attachment for every line. In this case the VBA will not finish.

    Sub Excel_Serial_Mail()
    
    
     Dim objOLOutlook As Object  
     Dim objOLMail As Object 
     Dim lngMailNr As Long  
     Dim lngZaehler As Long  
     
     Set objOLOutlook = CreateObject("Outlook.Application")
     lngMailNr = ActiveSheet.Cells(Rows.Count, 2).End(xlUp).Row 
    
     For lngZaehler = 2 To lngMailNr
     If Cells(lngZaehler, 2) <> "" Then
     Set objOLMail = objOLOutlook.CreateItem(olMailItem)
     With objOLMail
     .To = Cells(lngZaehler, 3)
     .CC = Cells(lngZaehler, 4)
     .BCC = "test@test.com"
     .SentOnBehalfOfName = "test@test.com"
     .Subject = Cells(lngZaehler, 6)
     .BodyFormat = olFormatPlain
     .Body = Cells(lngZaehler, 7)
     Dim strAttachmentPfad1 As String
     strAttachmentPfad1 = ActiveSheet.Cells(lngZaehler, 8)
     .Attachments.Add strAttachmentPfad1
     .Display
      End With
     Set objOLMail = Nothing
     End If
     Next lngZaehler  
     Set objOLOutlook = Nothing
    
     Exit Sub
    
     End Sub
    Last edited by torti111; 04-28-2016 at 03:05 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Vba save as pdf code problem in code any help please ?
    By tytyseka in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-11-2015, 11:33 PM
  2. vba code problem
    By sianjialin in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-26-2013, 09:44 PM
  3. [SOLVED] Code Problem: How to Write this into a VBA code
    By rlkerr in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-28-2013, 02:46 AM
  4. Replies: 2
    Last Post: 01-22-2013, 07:09 AM
  5. [SOLVED] problem with code
    By Ana in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-27-2006, 07:25 AM
  6. [SOLVED] if & and code problem
    By jocker in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 01-06-2006, 09:30 AM
  7. VBA Code Problem
    By Shawn in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 07-19-2005, 12:05 AM

Tags for this Thread

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