goedenavond,
Mijn naam is Anja en ik ben nieuw op dit forum. Voor mijn nieuwe zaak wil ik graag boekhouden met excel. Hiervoor heb ik een opzet gedownload wat ik eel fijn vind werken. Er zit alleen een foutmelding in de macro voor het opslaan van de factuur. Ik plak hieronder de macro. In plaats van dat hij opslaat zegt hij er gaat iets mis.
Kan iemand mij vertellen wat ik moet veranderen zodat hij de facturen wel in een folder opslaat.
Sub KnopOpslaan()
On Error GoTo ErrHandler:
Dim FolderPath As String
FolderPath = Application.ActiveWorkbook.path
If Right(FolderPath, 1) <> "" Then
FolderPath = FolderPath & ""
End If
Dim jaar As Integer
jaar = Sheets("BasisInstellingen").Range("C5").Value
FolderPath = FolderPath & "Facturen" & jaar
If Dir(FolderPath, vbDirectory) = vbNullString Then
MkDir FolderPath
End If
i = 1
If isEmpty(Range("C13")) Then
pdfname = "Factuur"
Else
pdfname = "Factuur " & Range("C13")
End If
If Dir(FolderPath & "" & pdfname & ".pdf") <> "" Then
Do While Dir(FolderPath & "" & pdfname & ".pdf") <> ""
If isEmpty(Range("C13")) Then
pdfname = "Factuur " & " (" & i & ")"
Else
pdfname = "Factuur " & Range("C13") & " (" & i & ")"
End If
i = i + 1
If i = 100 Then
Exit Do
End If
Loop
End If
With ActiveSheet.PageSetup
.LeftMargin = Application.InchesToPoints(0.1)
.RightMargin = Application.InchesToPoints(0.1)
.TopMargin = Application.InchesToPoints(0.3)
.BottomMargin = Application.InchesToPoints(0.1)
.HeaderMargin = Application.InchesToPoints(0.1)
.FooterMargin = Application.InchesToPoints(0.1)
.CenterHorizontally = True
.CenterVertically = False
End With
ActiveSheet.Range("B1:F47").ExportAsFixedFormat Type:=xlTypePDF, Filename:=FolderPath & "" & pdfname & ".pdf", Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
:=False, OpenAfterPublish:=True
Exit Sub
ErrHandler:
MsgBox "Er is iets mis gegaan"
Resume Next
End Sub
Alvast erg bedankt.
Vriendelijke groet,
Anja
Mijn naam is Anja en ik ben nieuw op dit forum. Voor mijn nieuwe zaak wil ik graag boekhouden met excel. Hiervoor heb ik een opzet gedownload wat ik eel fijn vind werken. Er zit alleen een foutmelding in de macro voor het opslaan van de factuur. Ik plak hieronder de macro. In plaats van dat hij opslaat zegt hij er gaat iets mis.
Kan iemand mij vertellen wat ik moet veranderen zodat hij de facturen wel in een folder opslaat.
Sub KnopOpslaan()
On Error GoTo ErrHandler:
Dim FolderPath As String
FolderPath = Application.ActiveWorkbook.path
If Right(FolderPath, 1) <> "" Then
FolderPath = FolderPath & ""
End If
Dim jaar As Integer
jaar = Sheets("BasisInstellingen").Range("C5").Value
FolderPath = FolderPath & "Facturen" & jaar
If Dir(FolderPath, vbDirectory) = vbNullString Then
MkDir FolderPath
End If
i = 1
If isEmpty(Range("C13")) Then
pdfname = "Factuur"
Else
pdfname = "Factuur " & Range("C13")
End If
If Dir(FolderPath & "" & pdfname & ".pdf") <> "" Then
Do While Dir(FolderPath & "" & pdfname & ".pdf") <> ""
If isEmpty(Range("C13")) Then
pdfname = "Factuur " & " (" & i & ")"
Else
pdfname = "Factuur " & Range("C13") & " (" & i & ")"
End If
i = i + 1
If i = 100 Then
Exit Do
End If
Loop
End If
With ActiveSheet.PageSetup
.LeftMargin = Application.InchesToPoints(0.1)
.RightMargin = Application.InchesToPoints(0.1)
.TopMargin = Application.InchesToPoints(0.3)
.BottomMargin = Application.InchesToPoints(0.1)
.HeaderMargin = Application.InchesToPoints(0.1)
.FooterMargin = Application.InchesToPoints(0.1)
.CenterHorizontally = True
.CenterVertically = False
End With
ActiveSheet.Range("B1:F47").ExportAsFixedFormat Type:=xlTypePDF, Filename:=FolderPath & "" & pdfname & ".pdf", Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
:=False, OpenAfterPublish:=True
Exit Sub
ErrHandler:
MsgBox "Er is iets mis gegaan"
Resume Next
End Sub
Alvast erg bedankt.
Vriendelijke groet,
Anja