"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
>
>
>
>
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 ...
"keepitcool" <xrrcv...@puryyb.ay> schreef in bericht
news:Xns9276F20D483...@207.46.239.39...
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...
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 ...
"keepitcool" <xrrcv...@puryyb.ay> schreef in bericht
news:Xns92777ABA83F...@207.46.239.39...
"Rinus Snoep" <snoe...@tholen.nl> schreef in bericht
news:akfh36$duj$1...@news1.megaplex.nl...