Results 1 to 4 of 4
  1. #1
    skaswani is offline Novice
    Windows XP Access 2007
    Join Date
    Dec 2010
    Posts
    3

    Send email from Access DB Table

    I m using Excel 2007, Access 2007 and Outlook



    i have a table in Access - Emails

    with 2 fields,
    1) Branch Code
    2) Email

    this is my code and what i want to do it i want to send email to the particular branch

    Code:
     
    Sub DistributeRows()
    Dim wbNew As Workbook
    Dim wsData As Worksheet
    Dim wsCrit As Worksheet
    Dim wsNew As Worksheet
    Dim rngCrit As Range
    Dim LastRow As Long
     
        Set wsData = Worksheets("LOAD DATA")
        Set wsCrit = Worksheets.Add
     
        LastRow = wsData.Range("A" & Rows.Count).End(xlUp).Row
     
        wsData.Range("A1:A" & LastRow).AdvancedFilter Action:=xlFilterCopy, CopyToRange:=wsCrit.Range("A1"), Unique:=True
     
        Set rngCrit = wsCrit.Range("A2")
        While rngCrit.Value <> ""
            Set wsNew = Worksheets.Add
            wsData.Range("A1:Y" & LastRow).AdvancedFilter Action:=xlFilterCopy, CriteriaRange:=rngCrit.Offset(-1).Resize(2), CopyToRange:=wsNew.Range("A1"), Unique:=True
            wsNew.Name = rngCrit
            wsNew.Copy
            Set wbNew = ActiveWorkbook
            wbNew.SaveAs ThisWorkbook.Path & "\" & rngCrit & "-" & Format(Date, "dd mmm yy")
            wbNew.Close SaveChanges:=True
            Application.DisplayAlerts = False
            wsNew.Delete
            rngCrit.EntireRow.Delete
            Set rngCrit = wsCrit.Range("A2")
        Wend
     
        wsCrit.Delete
        Application.DisplayAlerts = True
    End Sub

    and please also help me to conver this code to ACESS code ( i dont know how to open the .xls file through access

    Thanks

  2. #2
    skaswani is offline Novice
    Windows XP Access 2007
    Join Date
    Dec 2010
    Posts
    3
    Please Help

  3. #3
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    If afraid you will simply need to be patient and wait for someone that has the necessary skills to assist. Believe me, if someone here knew how to help you they would have already jumped in.

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    I'll see if I can't muddle through this and help somehow. The code you posted looks like you are just dealing with Excel automation. What is it you want to email?

Please reply to this thread with any new information or opinions.

Similar Threads

  1. How can I send an email from access???
    By Asma in forum Programming
    Replies: 2
    Last Post: 12-07-2011, 07:49 AM
  2. Send email from Access thru Outlook
    By ZMAN in forum Forms
    Replies: 2
    Last Post: 11-27-2010, 06:10 PM
  3. send email from a form
    By maxbre in forum Programming
    Replies: 4
    Last Post: 11-12-2010, 01:43 AM
  4. Replies: 9
    Last Post: 10-09-2009, 08:15 AM
  5. Send email using SendObject instruction
    By stecco in forum Access
    Replies: 4
    Last Post: 09-09-2009, 01:55 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums