Chipley
02-24-2008, 06:43 AM
Hi,
I just joined this community today, so I'm a first time poster.
I have a question which I hope will be an easy answer. I am working on a script that will save all worksheets in a workbook to a.txt file. I have been receiving some help on the following script; however, there is an error, and I don't have enough experience with VBA to debug. When I run this script, I get an error stating "Compile error - User defined type not defined", which in turn points to 'd As DataObject'. Could someone possibly lend a helping hand and tell me where my n000b logic has gone wrong
Sub SaveAsTextFile()
Dim s As Worksheet
Dim d As DataObject
Set d = New DataObject
Open "c:\temp\mytest.txt" For Append As 1
For Each s In ThisWorkbook.Sheets
s.UsedRange.Copy
d.GetFromClipboard
Print #1, vbNewLine & s.Name & vbNewLine & String(Len(s.Name), "=")
Print #1, d.GetText
Next
Close 1
End Sub
Much appreciation for any help on a Sunday.
Cheers,
~Chipley
I just joined this community today, so I'm a first time poster.
I have a question which I hope will be an easy answer. I am working on a script that will save all worksheets in a workbook to a.txt file. I have been receiving some help on the following script; however, there is an error, and I don't have enough experience with VBA to debug. When I run this script, I get an error stating "Compile error - User defined type not defined", which in turn points to 'd As DataObject'. Could someone possibly lend a helping hand and tell me where my n000b logic has gone wrong
Sub SaveAsTextFile()
Dim s As Worksheet
Dim d As DataObject
Set d = New DataObject
Open "c:\temp\mytest.txt" For Append As 1
For Each s In ThisWorkbook.Sheets
s.UsedRange.Copy
d.GetFromClipboard
Print #1, vbNewLine & s.Name & vbNewLine & String(Len(s.Name), "=")
Print #1, d.GetText
Next
Close 1
End Sub
Much appreciation for any help on a Sunday.
Cheers,
~Chipley