My code is running fine until the 81st iteration loop. There are over 1000 rows that need to go through this loop. The code then randomly stops. There is some sort of automation error. Please assist!
sb.Delimiter = "_"
Set fs = CreateObject("Scripting.FileSystemObject")
Set myHtmlFile = fs.CreateTextFile("C:\Users\wsherow\Temp\MyHTMLfile.htm", True)
myHtmlFile.WriteLine (sb.ToString())
myHtmlFile.Close
Set IE = CreateObject("Internetexplorer.Application")
IE.Visible = False
This code is meant to append long strings together to create file paths that follow a certain naming convention. What you are looking at is the execution step in which the concatinated paths (that have been written to an HTM file format) are written to the cell.
Sub concentiateMAIN()
RowCount = 2
Dim ie As InternetExplorer
Set ie = New InternetExplorerMedium
Do While Cells(RowCount, 2) <> 0
concentiate
Range("IV" & RowCount).Value = sb
With CreateObject("Scripting.FileSystemObject")
Range("A" & RowCount) = .OpenTextFile("C:\Users\wsherow\Temp\MyHTMLfile.htm").ReadAll()
End With
RowCount = RowCount + 1
ie.Quit
Set ie = Nothing
Loop
End Sub
On Line: Set IE = CreateObject("Internetexplorer.Application")
Sub concentiate()
Dim CellValue As String
Dim sb
Set sb = New Class1
'14NM
sb.Append "14NM"
'WID___________________________________________________________________________
If Range("HG" & RowCount) = "Width" Then
sb.Append "WID"
If Range("HH" & RowCount) = "Line" Then
sb.Append "LINE"
End If
If Range("HH" & RowCount) = "Space" Then
sb.Append "SPACE"
End If
sb.Append Range("IC" & RowCount)
sb.Append Range("HN" & RowCount)
sb.Append Range("HO" & RowCount)
If Range("HY" & RowCount) = "Linear" Then
sb.Append "LINEAR"
End If
If Range("HY" & RowCount) = "Threshold" Then
sb.Append "THD"
End If
sb.Append "TH"
sb.Append Range("II" & RowCount)
End If
'ER___________________________________________________________________________
If Range("HG" & RowCount) = "Edge Roughness" Then
sb.Append "ER"
If Range("HH" & RowCount) = "Line" Then
sb.Append "LINE"
End If
If Range("HH" & RowCount) = "Space" Then
sb.Append "SPACE"
End If
sb.Append Range("IC" & RowCount)
sb.Append Range("HN" & RowCount)
sb.Append Range("HO" & RowCount)
If Range("HY" & RowCount) = "Linear" Then
sb.Append "LINEAR"
End If
If Range("HY" & RowCount) = "Threshold" Then
sb.Append "THD"
End If
sb.Append "TH"
sb.Append Range("II" & RowCount)
End If
'WR___________________________________________________________________________
If Range("HG" & RowCount) = "Width Roughness" Then
sb.Append "WR"
If Range("HH" & RowCount) = "Line" Then
sb.Append "LINE"
End If
If Range("HH" & RowCount) = "Space" Then
sb.Append "SPACE"
End If
sb.Append Range("IC" & RowCount)
sb.Append Range("HN" & RowCount)
sb.Append Range("HO" & RowCount)
If Range("HY" & RowCount) = "Linear" Then
sb.Append "LINEAR"
End If
If Range("HY" & RowCount) = "Threshold" Then
sb.Append "THD"
End If
sb.Append "TH"
sb.Append Range("II" & RowCount)
End If
'ELL___________________________________________________________________________
If Range("HG" & RowCount) = "Elipse" Then
sb.Append "ELL"
If Range("HG" & RowCount) = "Inner Diameter" Then
sb.Append "INNERD"
End If
If Range("HG" & RowCount) = "Outer Diamter" Then
sb.Append "OUTERD"
End If
If Range("HJ" & RowCount) = "Diameter" Then
sb.Append "DIA"
End If
If Range("HJ" & RowCount) = "X Diameter" Then
sb.Append "XDIA"
End If
If Range("HJ" & RowCount) = "Y Diameter" Then
sb.Append "YDIA"
End If
If Range("HJ" & RowCount) = "Major Axis" Then
sb.Append "MAG"
End If
If Range("HJ" & RowCount) = "Minor Axis" Then
sb.Append "MIN"
End If
sb.Append Range("HO" & RowCount)
If Range("HY" & RowCount) = "Linear" Then
sb.Append "LINEAR"
End If
If Range("HY" & RowCount) = "Differential" Then
sb.Append "DIFF"
End If
If Range("HY" & RowCount) = "Threshold" Then
sb.Append "THD"
End If
sb.Append "TH"
sb.Append Range("II" & RowCount)
End If
'DIA___________________________________________________________________________
If Range("HG" & RowCount) = "Diameter(Hole)" Then
sb.Append "DIA"
If Range("HG" & RowCount) = "Inner Diameter" Then
sb.Append "INNERD"
End If
If Range("HG" & RowCount) = "Outer Diamter" Then
sb.Append "OUTERD"
End If
'_______
If Range("HI" & RowCount) = "Multi Point" Then
sb.Append "MP"
sb.Append Range("HN" & RowCount)
sb.Append Range("HO" & RowCount)
If Range("HY" & RowCount) = "Linear" Then
sb.Append "LINEAR"
End If
If Range("HY" & RowCount) = "Differential" Then
sb.Append "DIFF"
End If
If Range("HY" & RowCount) = "Threshold" Then
sb.Append "THD"
End If
sb.Append Range("IC" & RowCount)
End If
If Range("HI" & RowCount) = "Single" Then
sb.Append "SINGLE"
If Range("HY" & RowCount) = "Linear" Then
sb.Append "LINEAR"
End If
If Range("HY" & RowCount) = "Differential" Then
sb.Append "DIFF"
End If
If Range("HY" & RowCount) = "Threshold" Then
sb.Append "THD"
End If
sb.Append Range("IF" & RowCount)
End If
If Range("HI" & RowCount) = "Radial" Then
sb.Append "RAD"
If Range("HJ" & RowCount) = "Diameter" Then
sb.Append "DIA"
End If
If Range("HJ" & RowCount) = "X Diameter" Then
sb.Append "XDIA"
End If
If Range("HJ" & RowCount) = "Y Diameter" Then
sb.Append "YDIA"
End If
If Range("HJ" & RowCount) = "Major Axis" Then
sb.Append "MAG"
End If
If Range("HJ" & RowCount) = "Minor Axis" Then
sb.Append "MIN"
End If
sb.Append Range("HM" & RowCount)
If Range("HY" & RowCount) = "Linear" Then
sb.Append "LINEAR"
End If
If Range("HY" & RowCount) = "Differential" Then
sb.Append "DIFF"
End If
If Range("HY" & RowCount) = "Threshold" Then
sb.Append "THD"
End If
sb.Append Range("IC" & RowCount)
End If
sb.Append "TH"
sb.Append Range("II" & RowCount)
End If
'______
sb.Delimiter = "_"
Set fs = CreateObject("Scripting.FileSystemObject")
Set myHtmlFile = fs.CreateTextFile("C:\Users\wsherow\Temp\MyHTMLfile.htm", True)
myHtmlFile.WriteLine (sb.ToString())
myHtmlFile.Close
Set IE = CreateObject("Internetexplorer.Application")
IE.Visible = False
IE.Navigate "C:\Users\wsherow\Temp\MyHTMLfile.htm"
IE.Quit
Set IE = Nothing
End Sub
