yoitsmejy
03-28-2011, 08:46 AM
I want to copy the entire workbook to a new workbook without copying the formulas in the original workbook. I do not need the workbook to be saved. I have a delimiter code that i would like to be applied to the new workbook. Please help me figure out the best way to do this. Thank you.The delimiter code are as follow:
Sub SaveText()
Const DELIMITER As String = ","
Dim ws As Worksheet
Dim myRecord As Range
Dim myField As Range
Dim nFileNum As Long
Dim sOut As String
For Each ws In ActiveWorkbook.Worksheets
Set myRecord = Application.Intersect(ws.UsedRange, _
ws.Columns(ActiveCell.Column))
nFileNum = FreeFile
Open "C:\Documents" & ws.Name & ".txt" For Output As #nFileNum
For Each myRecord In ws.Range("A1:A" & _
ws.Range("A" & Rows.Count).End(xlUp).Row)
With myRecord
For Each myField In Range(.Cells(1), _
.Cells(.Row, Columns.Count).End(xlToLeft))
sOut = sOut & DELIMITER & myField.Text
Next myField
Print #nFileNum, Mid(sOut, 2)
sOut = Empty
End With
Next myRecord
Close #nFileNum
Next ws
End Sub
Sub SaveText()
Const DELIMITER As String = ","
Dim ws As Worksheet
Dim myRecord As Range
Dim myField As Range
Dim nFileNum As Long
Dim sOut As String
For Each ws In ActiveWorkbook.Worksheets
Set myRecord = Application.Intersect(ws.UsedRange, _
ws.Columns(ActiveCell.Column))
nFileNum = FreeFile
Open "C:\Documents" & ws.Name & ".txt" For Output As #nFileNum
For Each myRecord In ws.Range("A1:A" & _
ws.Range("A" & Rows.Count).End(xlUp).Row)
With myRecord
For Each myField In Range(.Cells(1), _
.Cells(.Row, Columns.Count).End(xlToLeft))
sOut = sOut & DELIMITER & myField.Text
Next myField
Print #nFileNum, Mid(sOut, 2)
sOut = Empty
End With
Next myRecord
Close #nFileNum
Next ws
End Sub