Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Probleem bij met macro .csv bestand maken

364 views
Skip to first unread message

Gerrit Snel

unread,
Aug 26, 2002, 4:48:49 PM8/26/02
to
Nog een opmerking: In Excel 2000 gaat het bij mijn weten wel goed, maar ik
heb het nodig in Excel 97.


"Gerrit Snel" <gs...@hotmail.com> schreef in bericht
news:xtwa9.2210$Br2.6160@amstwist00...
> Als ik in Excel 97 een werkblad opsla als .csv bestand, dan wordt alles
> opgeslagen met ; (puntkomma) als scheidingsteken en . (punt) als
> duizendtalscheiding en , (komma) als decimaalsymbool.
>
> Omdat ik deze handeling vaak moet doen heb ik het opgenomen als macro, wat
> de volgende code oplevert:
>
>
> ActiveWorkbook.SaveAs FileName:="c:\uitvoer.csv", FileFormat:= _
> xlCSV, CreateBackup:=False
>
> Voer ik dit echter uit, dan wordt het bestand opgeslagen met , (komma) als
> scheidingsteken en , (komma) als duizendtalscheidingsteken en . (punt) als
> decimaalsymbool. Als er een komma als duizendtalscheidingsteken gebruikt
is,
> dan staat het getal ook nog eens tussen ".
>
> Hoe kan ik er voor zorgen dat met een macro het bestand net zo wordt als
> wanneer ik het handmatig doe, dus met ; en 1.000,00.
>
> Groeten, Gerrit Snel
>
>
>
>


Gerrit Snel

unread,
Aug 26, 2002, 4:47:25 PM8/26/02
to

keepitcool

unread,
Aug 26, 2002, 5:47:03 PM8/26/02
to
Gerrit,

Als je t anders wilt moet je je regional settings in control panel
wijzigen.

list, descimal and thousands separator. deze worden voor csv export
gebruikt.


In excelXP kun je deze scheidingstekens specifiek voor Excel instellen,
vroeger kon dat naar mijn weten niet.
Zie in VBA application.international


Greetz,
KeepItCool
<unscramble emailaddress with ROT13>

"Gerrit Snel" <gs...@hotmail.com> wrote in message
news:Quwa9.2211$Br2.6189@amstwist00 ...

Gerrit Snel

unread,
Aug 26, 2002, 5:53:10 PM8/26/02
to
Daar staat het zoals ik het wil hebben

"keepitcool" <xrrcv...@puryyb.ay> schreef in bericht
news:Xns9276F20D483...@207.46.239.39...

Rinus Snoep

unread,
Aug 27, 2002, 5:34:16 AM8/27/02
to
Bekend probleem.

In nieuwsgroep micirsoft.public.nl.office.Excel is er meer over geschreven.

' aanroep ExportToTextFile waarbij
' FName = de bestandsnaam
' Sep = scheidingsteken bijvoorbeeld :
' SelectionOnly = True of False. Je kan dan ook een selectie exporteren.

'txt bestand genereren
Public Sub ExportToTextFile(FName As String, Sep As String, SelectionOnly As
Boolean)
Dim WholeLine As String
Dim FNum As Integer
Dim RowNdx As Long
Dim ColNdx As Integer
Dim StartRow As Long
Dim EndRow As Long
Dim StartCol As Integer
Dim EndCol As Integer
Dim CellValue As String


Application.ScreenUpdating = False
On Error GoTo EndMacro:
FNum = FreeFile

If SelectionOnly = True Then
With Selection
StartRow = .Cells(1).Row
StartCol = .Cells(1).Column
EndRow = .Cells(.Cells.Count).Row
EndCol = .Cells(.Cells.Count).Column
End With
Else
With ActiveSheet.UsedRange
StartRow = .Cells(1).Row
StartCol = .Cells(1).Column
EndRow = .Cells(.Cells.Count).Row
EndCol = .Cells(.Cells.Count).Column
End With
End If
iAantal = EndRow - StartRow + 1
Open FName For Output Access Write As #FNum

For RowNdx = StartRow To EndRow
WholeLine = ""
For ColNdx = StartCol To EndCol
If Cells(RowNdx, ColNdx).Value = "" Then
'CellValue = Chr(34) & Chr(34)
CellValue = ""
Else
CellValue = _
Application.WorksheetFunction.text _
(Cells(RowNdx, ColNdx).Value, _
Cells(RowNdx, ColNdx).NumberFormat)
End If
WholeLine = WholeLine & CellValue & Sep
Next ColNdx
WholeLine = Left(WholeLine, Len(WholeLine) - Len(Sep))
Print #FNum, WholeLine
Next RowNdx

EndMacro:
On Error GoTo 0
Application.ScreenUpdating = True
Close #FNum

End Sub


Rinus


"Gerrit Snel" <gs...@hotmail.com> schreef in bericht

news:9rxa9.2224$Br2.6244@amstwist00...

keepitcool

unread,
Aug 27, 2002, 6:03:17 AM8/27/02
to
Ik heb in de help maar eens de SaveAs method opgezocht:

het lijkt me dat vooral het laatste argument wel eens de oplossing kan
zijn:

Local Optional Variant. True saves files against the language of
Microsoft Excel (including control panel settings). False (default)
saves files against the language of Visual Basic for Applications (VBA)

Ergo, probeer t eens met:

ActiveWorkbook.SaveAs FileName:="c:\uitvoer.csv", FileFormat:= _

xlCSV, CreateBackup:=False, Local:=True


Greetz,
KeepItCool
<unscramble emailaddress with ROT13>

"Gerrit Snel" <gs...@hotmail.com> wrote in message

news:9rxa9.2224$Br2.6244@amstwist00 ...

Gerrit Snel

unread,
Aug 28, 2002, 2:30:23 AM8/28/02
to
Local:=True geeft een fout. Die kent ie niet.
Maar met de code van Rinus lukt het wel.

"keepitcool" <xrrcv...@puryyb.ay> schreef in bericht

news:Xns92777ABA83F...@207.46.239.39...

Gerrit Snel

unread,
Aug 28, 2002, 2:31:01 AM8/28/02
to
Dank je

"Rinus Snoep" <snoe...@tholen.nl> schreef in bericht
news:akfh36$duj$1...@news1.megaplex.nl...

0 new messages