Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Open file to write and read at the same time
http://support.microsoft.com/support...eio/fileio.asp
File Access with Visual Basic® for Applications Pretty vague just to say it doesn't work and put up 17 lines of code. Pehaps the above will give you some ideas. -- Regards, Tom Ogilvy mandy_less wrote in message ... Hi all, I'm trying to read the first line of a text file and write some lines to the same file if the file exists. Have tried the codes below but doesnt work! Start of code... ============================================= hFile = FreeFile 'Get the next free file handle nFile = FreeFile attachmentpath = "C:\test.txt" If Len(Dir(attachmentpath)) = 0 Then Open attachmentpath For Output Access Write Shared As _ hFile Print #hFile, "test msg" , strInput Else Open attachmentpath For Input Access Read Shared As _ nFile Line Input #nFile, strline Close #nFile Open attachmentpath For Output Access Write Lock Read _ Write As hFile Print #hFile, "test msg" , strInput End If Close hFile Close nFile ============================================== End of code... Thanks in advance ------------------------------------------------ ~~ Message posted from http://www.ExcelTip.com/ ~~ View and post usenet messages directly from http://www.ExcelForum.com/ |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
how can i open the write protected excel file? | Excel Discussion (Misc queries) | |||
HOW TO OPEN A WRITE PROTECTED FILE (USB) | Excel Discussion (Misc queries) | |||
I have a read only xl file, I need it to be read and write | Excel Discussion (Misc queries) | |||
read only file-need to write | Excel Discussion (Misc queries) | |||
How can a file be converted from Read-Only to Read/Write | Excel Discussion (Misc queries) |