ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Appending to File (https://www.excelbanter.com/excel-programming/277671-appending-file.html)

Progster

Appending to File
 
I've got a large macro which reads an input file, massages it in various
ways, and then writes multiple output files. Here is the code that writes
the output files. The key point is that already existing copies of the
files are simply overwritten.


' Upon reaching the end of the input file, activate each of the output
document files
' in turn and write them out.
If EOF(1) Then
Close #1
'Set MyOpen = Nothing
'iOpen = 0
'GoTo again:
For i = 0 To iNoFiles
Windows(sFileName(i)).Activate
ActiveDocument.SaveAs FileName:=sFileName(i),
fileformat:=wdFormatText
ActiveDocument.Close ' close the document after saving it
Next
End
End If


I would like to be able to append instead of overwrite. IOW, there may be
preexisting copies of any of the sFileName(i) files already on disk. If so,
I don't want to overwrite them, I want to append the new document (in Word)
to the old document (on disk).

I would appreciate any tips (or code) which would guide me in how to do
this. Thanks!

Progster

Appending to File
 
Thanks for your reply, Tom!

As it happens, this VBA macro has Word origins.

Getting the behavior I'm aiming at is clearly going to be more hassle than I
had hoped. :^(




All times are GMT +1. The time now is 02:28 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com