I have an Excel Workbook set up already that automatically attaches a specific file for each Sales Rep and e-mails it to them when I run the macro. I have now modified their individual files so that they are indexing information from another file. What I would like to do, is add functionality to this existing VBA to refresh each one of the files before it e-mails it, rather than me having to go in and refresh each one manually before running this script. Is this possible? This is one of the scrips for Austin that I have currently.
Sub Austin()
Dim edress As String
Dim subject As String
Dim message As String
Dim fileName As String
Dim outlookapp As Object
Dim myAttachments As Object
Dim path As String
Dim lastrow As Integer
Dim attachment As String
Dim x As Integer
x = 6
y = 2
Z = 3
Do While Sheets("Austin").Cells(x, 1) <> ""
Set outlookapp = CreateObject("Outlook.Application")
Set outlookmailitem = outlookapp.createitem(0)
Set myAttachments = outlookmailitem.Attachments
path = Sheets("Austin").Range("B2")
edress = Sheets("Austin").Cells(x, 1)
subject = Sheets("Austin").Cells(x, 2)
fileName = Sheets("Austin").Cells(x, 3)
attachment = path & fileName
outlookmailitem.To = edress
outlookmailitem.cc = Sheets("Main").Range("B15")
outlookmailitem.bcc = ""
outlookmailitem.subject = subject
outlookmailitem.body = Sheets("Austin").Cells(Z, 2)
myAttachments.Add (attachment)
outlookmailitem.display
outlookmailitem.send
lastrow = lastrow + 1
edress = ""
x = x + 1
Loop
Set outlookapp = Nothing
Set outlookmailitem = Nothing
End Sub
Sub Austin()
Dim edress As String
Dim subject As String
Dim message As String
Dim fileName As String
Dim outlookapp As Object
Dim myAttachments As Object
Dim path As String
Dim lastrow As Integer
Dim attachment As String
Dim x As Integer
x = 6
y = 2
Z = 3
Do While Sheets("Austin").Cells(x, 1) <> ""
Set outlookapp = CreateObject("Outlook.Application")
Set outlookmailitem = outlookapp.createitem(0)
Set myAttachments = outlookmailitem.Attachments
path = Sheets("Austin").Range("B2")
edress = Sheets("Austin").Cells(x, 1)
subject = Sheets("Austin").Cells(x, 2)
fileName = Sheets("Austin").Cells(x, 3)
attachment = path & fileName
outlookmailitem.To = edress
outlookmailitem.cc = Sheets("Main").Range("B15")
outlookmailitem.bcc = ""
outlookmailitem.subject = subject
outlookmailitem.body = Sheets("Austin").Cells(Z, 2)
myAttachments.Add (attachment)
outlookmailitem.display
outlookmailitem.send
lastrow = lastrow + 1
edress = ""
x = x + 1
Loop
Set outlookapp = Nothing
Set outlookmailitem = Nothing
End Sub