View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
ww ww is offline
external usenet poster
 
Posts: 6
Default Print# Statement | Leading zeroes

Hello

I am using the Print Statement to create a comma separated, quotes
file.

One of the data is a value with a leading zero "0234".

I have tracked its "print" to the OpenFile and it appears to print and
exist as "0234" until the Close# Command. Debug.Print shows the datum
to remain "0234" until the Close command which automatically converts
it to "0". :-/

I am looking for ways to Print "0233" without it being interpreted as
a number. i have included a portion of the code below which has been
modified from the Knowledge Base solution for CommaQuotes files:

For RowCount = 1 To UBound(TheArray, 1)

' Loop for each column in selection.
For ColumnCount = 1 To UBound(TheArray, 2)
sVal = Format(TheArray(RowCount, ColumnCount), "")
' Write current cell's text to file with quotation
marks.
Print #FileNum, """" & sVal & """";

' Check if cell is in last column.
If ColumnCount = UBound(TheArray, 2) Then
' If so, then write a blank line.
Print #FileNum,
Else
' Otherwise, write a comma.
Print #FileNum, ",";
End If
' Start next iteration of ColumnCount loop.
Next ColumnCount
' Start next iteration of RowCount loop.
Next RowCount

' Close destination file.
Close #FileNum
End Sub

Thanks in advance.

W