i'm trying to export all my sheets in my workbook at once as image. The final goal should be to open the macro or press an button and then all the worksheets are exported to an directory named as "worksheet".jpg and they should have the exact same size, for example. I tried to add some extra code to this, which i found somewhere:
Sub SaveStaticImageWorkbook()
Dim ws As Worksheet, wb As Workbook, fDialog As FileDialog
Application.DisplayAlerts = False
Set wb = Workbooks.Add
wb.Sheets(1).Name = "Tmp123"
For Each ws In ThisWorkbook.Worksheets
ws.Copy After:=wb.Sheets(wb.Sheets.Count)
Next ws
'Remove Sheet1
wb.Sheets("Tmp123").Delete
For Each ws In wb.Worksheets
ws.Range(ws.Cells(1, 1), ws.Cells.SpecialCells(xlLastCell)).Copy
ws.Select
ws.Cells(1, 1).Select
ws.Pictures.Paste
ws.Range(ws.Cells(1, 1), ws.Cells.SpecialCells(xlLastCell)).Clear
Next ws
Set fDialog = Application.FileDialog(msoFileDialogSaveAs)
fDialog.Title = "Save Static Workbook"
fDialog.InitialFileName = ThisWorkbook.Path
If fDialog.Show = -1 Then
wb.SaveAs fDialog.SelectedItems(1)
End If
wb.Close SaveChanges:=False
Application.DisplayAlerts = True
End Sub
My problem is, that i have no idea, where i have to add this extra code. I have tried several options, for example to add it in the for loop, but this fails often in runtime errors. Maybe someone of you can help me.
Thanks