View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.misc
Jim Cone Jim Cone is offline
external usenet poster
 
Posts: 3,290
Default need to export row as csv file with column e plus .bom as file name

Rod,
This ought to get you almost there.
It uses the row that has the active cell in it.
It picks up the text using a variant array.
It then reads the data from the array into a string variable.
A new text file is opened using the Microsoft Scripting Runtime
FileSystemObject and the text is added to the file and the file is closed.

Sub AsRequested()
Dim oFSO As Object
Dim oFile As Object
Dim strRow As String
Dim strName As String
Dim strPath As String
Dim varRow As Variant
Dim lngR As Long
Dim N As Long

lngR = ActiveCell.Row
strName = Cells(lngR, 5).Value
strPath = "c:\tmp\" & strName & ".Bom"

varRow = Array(Cells(lngR, 1).Value, Cells(lngR, 3).Value, _
Cells(lngR, 5).Value, ",", Cells(lngR, 8).Value, ",", _
Cells(lngR, 9).Value, ",", Cells(lngR, 6).Value, ",", _
Cells(lngR, 4).Value, ",", ",", ",", ",", Cells(lngR, 10).Value, _
",", ",", ",", ",", Cells(lngR, 20).Value)
For N = 0 To UBound(varRow)
strRow = strRow & varRow(N)
Next 'N

Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oFile = oFSO.CreateTextFile(strPath, True)
oFile.WriteLine (strRow)
oFile.Close

Set oFile = Nothing
Set oFSO = Nothing
End Sub
-----------
Jim Cone
San Francisco, USA
http://www.officeletter.com/blink/specialsort.html



"rod"

wrote in message
Jim
You are correct on that one for sure.
Text looked in order before I sent it out..
I hope it wont happen again.
I hope this is not too confusing the way I have explaind it here.

What I am trying to do is take a active row and export that row out as a
delimited file format .
Really just using columns A thru T that have any info in them per row.
Some of the colums in the row I am not using .
The cells in order needed in the output delimeted file would be
S,C,E,H,I,F,D,,,J,,,,T
The empty spaces in the delimited file could just be a cell that holds the
extra comma or however.
This means I need these empty spaces in the delimited file, not other cells
in the excel file that hold no value.

In the column J of the excel file there is a date, this is displayed as
10/25/06.
This is how the date info is placed into the excel file from an as400 dat
file that someone else does for us.
But need the this Date output in a different format.
Example
Excel Exported columns - s ,c
,e ,h ,i ,f ,d ,,,j ,,,,t
Would look like this-
g:\sigma\sndata55\parts55\312944\599-020d,g,32,p,862423,,,2006/10/25,,,,donefile2
That means I have joined colums S,C,E,H,I,F,D (PLUS 2 EMPTY SPACES) then J
(PLUS 3 EMPTY SPACES) then T of the target row .

The delimited file would need be saved as c:\tmp\599-020d.bom
That means delimited file would use value of cell in column E in that active
row for file name and have an extension of .BOM for file name.
The cells in column U could have the action code or trigger in each cell to
create the delimeted file for that active row , pasteddown sheet of column U .
Like active row is on A3 , click on cell in U3 and delimted file be created
for that row A3 .
I can explain more orget you a small excel file example, and a Bom file if
it will help any further ..
I use this below , then copy the cell value into notepad and then save the
file as 599-020d.bom
=A3&C3&E3&","&H3&","&I3&","&F3&","&D3&","&","&","& J3&","&","&","&","&","&T3

G:\SIGMA\SNDATA55\PARTS55\312944\599-020D,G,32,P,1122445,,,39015,,,,,DONEFILE2
As I mentioned before the date does not come out correct in what the above
function does so I wolud have to edit in notepad as 2006/10/25
and then save file again ..
I can explain more orget you a small excel file example, and a Bom file if
it will help any further ..
Thanks
Rod


"Jim Cone" wrote in message
...
Your message is pretty much jumbled up.
Suggest you try again with a revised example.
Using normal English grammar rules and punctuation will also help.
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware