![]() |
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 |
UDF Macro Looping Issue Erroring out
Anybody? I will even take some guesses at this point...
Tyson On Jun 1, 2:16*pm, Tysone wrote: 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 |
All times are GMT +1. The time now is 09:02 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com