Private Sub CommandButton9_Click()
Dim objBereik As Object, DoelRij As Object, Cel As Object
Dim strTemp As String
Dim strDataNaam As String
Dim strKoppelteken As String
Dim strMapPad As String
strMapPad = "C:\" & Sheets("invulblad type 4").Range("D3").Value & ".csv"
strDataNaam = InputBox("Project klaar voor importeren in Gurbesoft? Zo ja, voer hieronder het projectnummer in.", "CSV-Export", strMapPad)
If strDataNaam = "" Then Exit Sub
strKoppelteken = InputBox(",", "CSV-Export", ",")
If strKoppelteken = "" Then Exit Sub
Set objBereik = Sheets("Gurbesoft").UsedRange
Open strDataNaam For Output As #1
For Each DoelRij In objBereik.Rows
If DoelRij.Hidden = False Then
Dim iRow As Integer
Const shtNaam = "Gurbesoft"
For iRow = 1 To Sheets(shtNaam).UsedRange.Rows.Count
If Sheets(shtNaam).Cells(iRow, 3) = 0 Then
Sheets(shtNaam).Rows(iRow).Hidden = True
Else
Sheets(shtNaam).Rows(iRow).Hidden = False
End If
Next iRow
End If
For Each Cel In DoelRij.Cells
If Not IsEmpty(Cel.Value) Then
If InStr(1, Cel.Text, strKoppelteken) > 0 Then
'Cellen met splitsteken in rij zetten
strTemp = strTemp & """" & CStr(Cel.Text) & """" & strKoppelteken
Else
strTemp = strTemp & CStr(Cel.Text) & strKoppelteken
End If
End If
Next
If Right(strTemp, 1) = strKoppelteken Then strTemp = Left(strTemp, Len(strTemp) - 1)
If Not (strTemp = "") Then
Print #1, strTemp
strTemp = ""
End If
Next
Close #1
Set Bereik = Nothing
MsgBox "Data geexporteerd naar" & vbCrLf & strDataNaam
Dim blad As Worksheet
Application.ScreenUpdating = False
For Each blad In ActiveWorkbook.Worksheets
If blad.Visible = xlSheetVisible Then blad.PrintOut
Next blad
Application.ScreenUpdating = False
End Sub