View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Tysone Tysone is offline
external usenet poster
 
Posts: 17
Default UDF Macro Looping Issue Erroring out

I'm having a little issue with my macro and I think my UDF is the
problem.

Big picture is that my macro loops though my work email list, adds
attachments and a body just fine for my first name, but it catches
when it goes to name two. Can someone help me fix my code?

Thanks for your time,

Tyson



Function Get_Body() As String
Dim ie As Object, nav As String
Dim Cell As Range
Dim I As Long

Start = frmPrintFile.txtFirst.Text + 1
Finish = frmPrintFile.txtLast.Text + 1
For Each Cell In Range("A" & Start & ":A" & Finish).Cells

nav = Cell.Offset(0, 3).Value
Set ie = CreateObject("InternetExplorer.Application")
With ie
ie.Visible = False
ie.navigate nav
Do Until .ReadyState = 4
Loop
Get_Body = .Document.body.InnerHTML
.Quit

End With
Next
Set ie = Nothing
End Function

Function Get_Body2() As String
Dim ie As Object, nav2 As String
Dim Cell As Range
Dim I As Long

Start = frmPrintFile.txtFirst.Text + 1
Finish = frmPrintFile.txtLast.Text + 1
For Each Cell In Range("A" & Start & ":A" & Finish).Cells

nav2 = Cell.Offset(0, 4).Value
Set ie = CreateObject("InternetExplorer.Application")
With ie
ie.Visible = False
ie.navigate nav2
'.navigate "C:\Documents and Settings\tedwards\test
attachment.htm"
Do Until .ReadyState = 4
Loop
Get_Body2 = .Document.body.InnerHTML
.Quit

End With
Next
Set ie = Nothing
End Function