printing to a text file

B

Becky

hi to all

Here's a snippet from some of Allen Browne's code.

For Each ctl In frm
For Each prp In ctl.Properties
strOut = strFormName & "." & ctl.Name & "." & prp.Name & ": "
strOut = strOut & prp.Type & vbTab
strOut = strOut & prp.Value
Debug.Print strOut
Next
If ctl.ControlType = acTextBox Then Stop
Next

Instead of printing the output to the immediate window, how do I print it to
a Notepad text file?

Thank you
Becky
 
D

Douglas J. Steele

Dim intFile As Integer
Dim strFile As String

strFile = "C:\Folder\File.txt"
intFile = FreeFile()
Open strFile For Output As #intFile
For Each ctl In frm
For Each prp In ctl.Properties
strOut = strFormName & "." & ctl.Name & "." & prp.Name & ": "
strOut = strOut & prp.Type & vbTab
strOut = strOut & prp.Value
Print #intFile, strOut
Next
If ctl.ControlType = acTextBox Then
Close #intFile
Stop
End If
Next
Close #intFile
 
B

Becky

Yes! thanks very much Douglas.
Becky

Douglas J. Steele said:
Dim intFile As Integer
Dim strFile As String

strFile = "C:\Folder\File.txt"
intFile = FreeFile()
Open strFile For Output As #intFile
For Each ctl In frm
For Each prp In ctl.Properties
strOut = strFormName & "." & ctl.Name & "." & prp.Name & ": "
strOut = strOut & prp.Type & vbTab
strOut = strOut & prp.Value
Print #intFile, strOut
Next
If ctl.ControlType = acTextBox Then
Close #intFile
Stop
End If
Next
Close #intFile
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top