Reputation: 191
As a beginner, I wrote the following macro and saved it in the PERSONAL.XLSB.
I want the Excel, in the Part 6, to export the file to the same folder with the same filename. But the Part 6 does not run. Can anyone help me please?
Sub Aufräumen()
'
' Aufräumen Makro
'
'
' 1. Detele the "Mängelbericht":
Application.DisplayAlerts = False 'switching off the alert button
Sheets("Mängelbericht").Delete
Application.DisplayAlerts = True 'switching on the alert button
'
' 2. Cleaning the "Protokoll":
Sheets("Prtokoll").Select
Columns("M:U").Select
Selection.Delete Shift:=xlToLeft
Range("M1").Select
'
' 3. Cleaning the "Bestandaufnahme":
Sheets("Bestandaufnahme").Select
Columns("AB:AK").Select
Selection.Delete Shift:=xlToLeft
Range("AB1").Select
'
' 4. Cleaning the "Messungen":
Sheets("Messungen").Select
Columns("O:AD").Select
Selection.Delete Shift:=xlToLeft
Range("O1").Select
'
' 5. Back to start point
Sheets("Prtokoll").Select
Range("M1").Select
'
' 6. Save As PDF:
ActiveWorkbook.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
ThisWorkbook.Path & "\" & ThisWorkbook.Name, _
Quality:=xlQualityStandard, IncludeDocProperties:=True, _
IgnorePrintAreas:=False, OpenAfterPublish:=True
End Sub
Here is a screentshot of the debugger:
Upvotes: 0
Views: 322
Reputation: 997
When saving a macro to an xlsb (which is not the workbook the macro is running in), you will need to use active workbook instead of this workbook.
Upvotes: 2