Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default Trying to Append File using the example in excel but not working

Hello

Im trying to open a file and if it does not exist - then create it, and write to the end of it.
I have copied the example from help on "opentextfile method" and it does not work
Can anyone help
Thanks in advance
Susan

Sub OpenTextFileTest
Const ForReading = 1, ForWriting = 2, ForAppending = 3
Dim fs, f
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.OpenTextFile("c:\testfile.txt", ForAppending,TristateFalse)
f.Write "Hello world!"
f.Close
End Sub



Aswell is it possible to insert a row without inserting it into column A?
ie column A has numbers 1,2,3... whcich are passed downward as the rows are inserted.
I have found a way around it by calculating this series in a do while loop. I would perfer to avoid this!
Thanks Again
Susan

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Trying to Append File using the example in excel but not working

I defined forappending = 8 and it worked ok:

Const ForReading = 1, ForWriting = 2, ForAppending = 8, TristateFalse = 0

(don't forget tristatefalse if you have Option explicit turned on.)



Susan Hayes wrote:

Hello

Im trying to open a file and if it does not exist - then create it, and write to the end of it.
I have copied the example from help on "opentextfile method" and it does not work
Can anyone help
Thanks in advance
Susan

Sub OpenTextFileTest
Const ForReading = 1, ForWriting = 2, ForAppending = 3
Dim fs, f
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.OpenTextFile("c:\testfile.txt", ForAppending,TristateFalse)
f.Write "Hello world!"
f.Close
End Sub

Aswell is it possible to insert a row without inserting it into column A?
ie column A has numbers 1,2,3... whcich are passed downward as the rows are inserted.
I have found a way around it by calculating this series in a do while loop. I would perfer to avoid this!
Thanks Again
Susan


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Trying to Append File using the example in excel but not working

Not sure what you mean for the second question, but maybe you could just insert
columns B:IV and shift down?

(or just renumber column A?)

Susan Hayes wrote:

Hello

Im trying to open a file and if it does not exist - then create it, and write to the end of it.
I have copied the example from help on "opentextfile method" and it does not work
Can anyone help
Thanks in advance
Susan

Sub OpenTextFileTest
Const ForReading = 1, ForWriting = 2, ForAppending = 3
Dim fs, f
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.OpenTextFile("c:\testfile.txt", ForAppending,TristateFalse)
f.Write "Hello world!"
f.Close
End Sub

Aswell is it possible to insert a row without inserting it into column A?
ie column A has numbers 1,2,3... whcich are passed downward as the rows are inserted.
I have found a way around it by calculating this series in a do while loop. I would perfer to avoid this!
Thanks Again
Susan


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using Excel VBA: sending output data table to created .csv file +append Options Mike Excel Discussion (Misc queries) 1 December 10th 11 12:39 PM
Is it possible to Append worksheets in the same excel file? Angie33 Excel Discussion (Misc queries) 3 August 7th 08 04:58 PM
Append Excel Sheet from constantly updating delimited text file Ker G Setting up and Configuration of Excel 1 April 8th 08 09:33 PM
how can I Append values to an existing excel file. viv New Users to Excel 0 March 21st 07 11:25 AM
Append the data given in diff sheets of an Excel File to one sheet sansk_23 Excel Worksheet Functions 3 May 10th 05 02:00 AM


All times are GMT +1. The time now is 05:24 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"