Hello Experts!
I am trying to convert several of the worksheets in my workbook to text files.
I tried saving each as a prn file, but some of the data was getting cut off.
Next I tried this:
This works for all of my worksheets except one. That worksheet randomly freezes in the middle, stopping the entire process. I have identified that it always freezes on one specific column, but the "freeze row" varies.
I never even get to the error handler - it just quits in the middle.
Any suggestions?
Thanks!
TemiU
I am trying to convert several of the worksheets in my workbook to text files.
I tried saving each as a prn file, but some of the data was getting cut off.
Next I tried this:
Code:
'loop worksheets one by one, open file "WkshtName.prn" as #1 for output and call:
Sub WriteToFile(mySheet As Worksheet, intColCount As Integer, path As String)
Dim intRowNum As Integer, j As Integer
Dim strWholeLine As String
Dim myCell As Range
Dim prnFile2 As String
Application.ScreenUpdating = False
For intRowNum = 1 To mySheet.UsedRange.Rows.Count
'only write this row if not hidden
If Range("A1").Offset(intRowNum - 1, 0).Rows(1).Hidden = False Then
For j = 1 To intColCount
'only write this column if not hidden
If Range("A1").Offset(, j - 1).Columns(1).Hidden = False Then
Set myCell = Range("A1").Offset(intRowNum - 1, j - 1)
myCell.Activate
strWholeLine = strWholeLine & myCell.Text & PadBlanks(myCell.Width / 4 - Len(myCell.Text))
End If
Next j
Print #1, strWholeLine
strWholeLine = ""
End If
Next intRowNum
ErrExit:
Close #1
Application.ScreenUpdating = True
Exit Sub
ErrHandle:
MsgBox "Line: " & intRowNum & " Col: " & j & " Text: " & ActiveCell(intRowNum, j).Text
MsgBox Err.number & ": " & Err.Description
Resume ErrExit
End Sub
This works for all of my worksheets except one. That worksheet randomly freezes in the middle, stopping the entire process. I have identified that it always freezes on one specific column, but the "freeze row" varies.
I never even get to the error handler - it just quits in the middle.
Any suggestions?
Thanks!
TemiU