ich will ein einzelnes Worksheet aus einem Workbook abspeichern. Leider speichert mir mein Makro immer das komplette Workbook ab. Hier der entsprechende Code:
Sheets("Protokoll").Copy
n = Range("C2").Value
Range(Cells(4, 2), Cells(n + 4, 7)).Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.ThemeColor = 1
.TintAndShade = -0.149998474074526
.Weight = xlThin
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.ThemeColor = 1
.TintAndShade = -0.149998474074526
.Weight = xlThin
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.ThemeColor = 1
.TintAndShade = -0.149998474074526
.Weight = xlThin
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.ThemeColor = 1
.TintAndShade = -0.149998474074526
.Weight = xlThin
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.ThemeColor = 1
.TintAndShade = -0.149998474074526
.Weight = xlThin
End With
With Selection.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.ThemeColor = 1
.TintAndShade = -0.149998474074526
.Weight = xlThin
End With
datum1 = Range("Protokoll!H2")
datum2 = Range("Protokoll!I2")
datum3 = Range("Protokoll!J2")
varFilename = Application.GetSaveAsFilename( _
InitialFileName:="Protokoll" & "_" & datum1 & "_" & datum2 & "_" & datum3 & ".pdf", _
FileFilter:="PDF (*.pdf), *.pdf", _
Title:="als PDF speichern")
If varFilename False Then
ThisWorkbook.ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:=varFilename
End If
Application.DisplayAlerts = False
ActiveWorkbook.Close
Application.DisplayAlerts = True
Findet jemand den Fehler?
Vielen Dank schonmal und liebe Grüße