PDA

View Full Version : Solved: Specify Delimiter in Word Form in Save as Text



wezred
06-26-2007, 03:02 AM
My forms has commas "," in the values and exporting it to a delimited file will mess with the data since commas "," is used as the delimiter.:banghead:

Any way for me to specify the delimiter used (like "|") in vba? A macro that saves only form data into TXT but asking first to specify the delimiter would be great.:bow:

Any help is appreciated. See attached for example.:dunno

mdmackillop
06-30-2007, 10:43 AM
Option Explicit
Sub FField()
Dim f As FormField
Dim Delim As String
Dim txt As String
Delim = InputBox("Enter delimiter", , "|")
For Each f In ActiveDocument.FormFields
txt = txt & f.Result & Delim
Next
txt = Left(txt, Len(txt) - 1)
Documents.Add
Selection.TypeText txt
ActiveDocument.SaveAs "C:\MyTest.txt", wdFormatDOSText
End Sub

wezred
07-02-2007, 08:39 PM
Interesting alternative solution.

Thanks for the help.

mdmackillop
07-03-2007, 04:59 AM
I never thought about an existing txt file. If you need to append the text, let us know.