Thread: How can I...
View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Rick Rothstein \(MVP - VB\)[_2320_] Rick Rothstein \(MVP - VB\)[_2320_] is offline
external usenet poster
 
Posts: 1
Default How can I...

Replace all the code you posted with this...

If Option1 = True Then BEAVIS = "Silex,186Y9Y"
If Option2 = True Then BEAVIS = "Customer," + Text25.Text
Err.Clear ' I wasn't sure about this line, but left it in because you had
it
REDDYFILE = "C:\Documents and Settings\Silex Dock\" & _
"Desktop\Shipment History CSVFILE.csv "
ALLINFOV = Text2.Text & "," & Text3.Text & "," & Text4.Text & _
"," & Combo1.Text & "," & Text6.Text & "," & Text7.Text & _
"," & BEAVIS & "," & Text8.Text & "," & Text5.Text & _
"," & Text26.Text & "," & Text1.Text & "," & Text27.Text & _
"," & Text28.Text & "," & Text29.Text & "," & Text30.Text & _
"," & Text32.Text
Text31.Text = ALLINFOV
Answer = MsgBox("Is everything OK?", vbQuestion Or vbYesNo, "Verifying")
If Answer = vbYes Then
FF = FreeFile
Open "c:\Your\Path\And\Filename.csv" For Append As #FF
Print #FF, "Your Line of comma separated text"
Close #FF
End If

And add this declaration to the section where you declared your other
variables...

Dim FF As Long
Dim Answer As Long

Note that I neatened up the long lines using line continuations so they
won't split apart awkwardly in your newsreader. I also added some structure
around the MsgBox to accept an answer to your question and then properly
handle it.

Rick


"markythesk8erboi" wrote in
message ...
Ok, um...... This is the code I have so I'm gonna need help changing it.

'Writing the stuff to a file
'1)setting variables


If Option1 = True Then BEAVIS = "Silex,186Y9Y"
If Option2 = True Then BEAVIS = "Customer," + Text25.Text
'end of setting "bill to" option variables

REDDYFILE = "C:\Documents and Settings\Silex Dock\Desktop\Shipment History
CSVFILE.csv"
Err.Clear

Set XYZZYX = CreateObject("Scripting.filesystemobject")
Set ABACABB = XYZZYX.createTextfile(REDDYFILE, True)

ALLINFOV = Text2.Text + "," + Text3.Text + "," + Text4.Text + "," +
Combo1.Text + "," + Text6.Text + "," + Text7.Text + "," + BEAVIS + "," +
Text8.Text + "," + Text5.Text + "," + Text26.Text + "," + Text1.Text + ","
+
Text27.Text + "," + Text28.Text + "," + Text29.Text + "," + Text30.Text +
","
+ Text32.Text
'now ALLINFOV is a variable that is equal to the entire line of info I
want
to write to file
Text31.Text = ALLINFOV 'now text31 is the line of ALLINFOV
MsgBox ("is everything ok") 'Pause before submittal

ABACABB.writeline (ALLINFOV) 'write ln
ABACABB.Close 'close file



Please keep in mind this is inside the sub routine of a command button and
if I need to create anything in the general scripting I need to know that.
I'm a noobie... sorry




"Rick Rothstein (MVP - VB)" wrote:

Something like this should work (substitute the sample filename and
output
line with your actual items...

Dim FF As Long
......
......
FF = FreeFile
Open "c:\Your\Path\And\Filename.csv" For Append As #FF
Print #FF, YourLineOfCommaSeparatedText
Close #FF

Rick


"markythesk8erboi" wrote in
message ...
Ok, I have a Visual Basic program that I would like to use to send
information into a worksheet designated as a Common Seperator Value
file.
So,
in my program I have set a single variable to contain all information
for
one
line seperated by commas (,) to distinguish which part of the line goes
into
which column. Now, as it stands this works beautifully with one MAJOR
exception- Every time I send the 'line' to the CSV file, it simply
overwrites
the previous data. What I want to happen is when I send the info to
excel
it
follows these steps (or at least to this effect):

1. Open the CSV file
2. Write Ln
3. Drop the cursor to the next row
4. Save and close the file

Can anyone help with this?