View Full Version : another VB question
Pi Man
06-26-2002, 05:29 PM
basic question - want to append an existing output file (if i close and re-open it looks like it over-writes...)
am i missing something ?
NoName
06-27-2002, 06:35 AM
No offense, but if your company still refuses to give you access to the help file there are some real problems there ... anyway, I think you want:
Open "hello.txt" for append as 1
I quote from the help:
Open Statement
Enables input/output (I/O) to a file.
Syntax
Open pathname For mode [Access access] [lock] As [#]filenumber [Len=reclength]
The Open statement syntax has these parts:
Part Description
pathname Required. String expression that specifies a file name — may include directory or folder, and drive.
mode Required. Keyword specifying the file mode: Append, Binary, Input, Output, or Random. If unspecified, the file is opened for Random access.
access Optional. Keyword specifying the operations permitted on the open file: Read, Write, or Read Write.
lock Optional. Keyword specifying the operations restricted on the open file by other processes: Shared, Lock Read, Lock Write, and Lock Read Write.
filenumber Required. A valid file number in the range 1 to 511, inclusive. Use the FreeFile function to obtain the next available file number.
reclength Optional. Number less than or equal to 32,767 (bytes). For files opened for random access, this value is the record length. For sequential files, this value is the number of characters buffered.
Remarks
You must open a file before any I/O operation can be performed on it. Open allocates a buffer for I/O to the file and determines the mode of access to use with the buffer.
If the file specified by pathname doesn't exist, it is created when a file is opened for Append, Binary, Output, or Random modes.
If the file is already opened by another process and the specified type of access is not allowed, the Open operation fails and an error occurs.
The Len clause is ignored if mode is Binary.
Important In Binary, Input, and Random modes, you can open a file using a different file number without first closing the file. In Append and Output modes, you must close a file before opening it with a different file number.
Visual Basic 6 Complete published by Sybex. The best 19.99 I've ever spent.
Pi Man
06-27-2002, 09:35 AM
No offense, but if your company still refuses to give you access to the help file there are some real problems there ...
you said a MOUTHful!! thanks for the response - i'll try it out!
Pi Man
07-01-2002, 04:54 PM
STILL no progress with getting help files...
this is part of a larger need;
i need a command that will name the ACTIVE (currently highlighted) region in Excel (just like entering a name in the Name Box). For example, user selects A5:Q18. Running the macro names that range "myRange."
easy to do??
whisper
07-01-2002, 05:14 PM
This'll name the current region of the active cell. You can modify it to you specific needs.
Sub Macro1()
Dim theWorkbook As Excel.Workbook
Dim theRange As Excel.Range
Set theWorkbook= ActiveWorkbook
Set theRange = ActiveCell.CurrentRegion
xclWB.Names.Add Name:="myrange", RefersTo:=theRange
End Sub
whisper
07-01-2002, 05:16 PM
STILL no progress with getting help files...
this is part of a larger need;
i need a command that will name the ACTIVE (currently highlighted) region in Excel (just like entering a name in the Name Box). For example, user selects A5:Q18. Running the macro names that range "myRange."
easy to do??
Excel has a macro recorder, so if it is something that it is easy to do in Excel, you might want to try to record it and then modify it. Not all commands in Excel are recordable, so it doesn't always work.
Pi Man
07-02-2002, 12:53 PM
Thanks for the help (and your patience). I tried recording, but the RefersTo gave me a headache... thanks again!
This results in "Run-time error '424': object required"
vBulletin® v3.7.6, Copyright ©2000-2013, Jelsoft Enterprises Ltd.