> Here's an alternative for Office versions XP up ...
>
[quoted text clipped - 40 lines]
> > End With
> > Set oFF = Nothing
> We are using Office XP. How do I write and save my "oFF( ).results" to the
> text file? With your code it opens a Look In dialog box not a Save As
> dialog
> box.
?
the FileDialog isn't used to save your textfile.
It is merely used to retrieve the textfile the user needs to select, to
write the results of the formfields to.
At least, this is what understood from yr initial post.
(If this assumption is not correct, than correct me :-)
I've combined my proposal to yr initial post, see below code.
Try the code, and pls check whether formfields data is actually written to
(and saved in) the textfile?
' Here is the code
Dim tempFile
Dim fd As FileDialog
Dim oFF as formfields
Dim i as integer
set oFF = activedocument.formfields
i = FreeFile()
Set fd = Application.FileDialog(3)
fd.Filters.Add "Text Files", "*.txt"
fd.FilterIndex = 0
fd.InitialFileName = "U:\History"
fd.AllowMultiSelect = False
If fd.Show Then
tempFile = fd.SelectedItems(i)
Open tempfile For Output As #i
Write #i, oFF(5).Result, oFF(6).Result, _
oFF(7).Result, oFF(8).Result, _
oFF(9).Result, oFF(10).Result
Close #i
End If
The code in words: FileDialog retrieves the name of the target textfile
selected by user.
The name of this textfile is used in the Open ... For Output command to open
an I/O channel to target textfile, using #i (retrieved by FreeFile function)
The results of the FormFields (5, 6, 7, 8, 9 and 10) are written to the
target textfile.
Data is written to textfile, so the I/O channel can be closed. If no errors
occur, all data is saved to this textfile ...
--
Krgrds,
Perry
System:
Vista/Office Ultimate
VS2005/VSTO2005 SE
> Hi Perry,
>
[quoted text clipped - 49 lines]
>> > End With
>> > Set oFF = Nothing
LEU - 12 Mar 2007 04:30 GMT
Thank you so much. This worked perfectly.
LEU
> > We are using Office XP. How do I write and save my "oFF( ).results" to the
> > text file? With your code it opens a Look In dialog box not a Save As
[quoted text clipped - 105 lines]
> >> > End With
> >> > Set oFF = Nothing
LEU - 12 Mar 2007 19:51 GMT
Perry,
I spoke to soon. Your code works great copying the text doc into my document
by changing the following line, “Open tempfile For Input As #i”, but the wat
it is writen it does not write from my document into a text document. When it
runs it calls up the browse dialog box. If I enter a new name to save it as
and click OK, nothing happens. Shouldn't it be opening the Save As dialog box?
LEU
> > We are using Office XP. How do I write and save my "oFF( ).results" to the
> > text file? With your code it opens a Look In dialog box not a Save As
[quoted text clipped - 105 lines]
> >> > End With
> >> > Set oFF = Nothing