Originally Posted by
o0omax
When and how often should i CreateObject("Excel.Application") ? For every Workbook i open?
i don't think you should use that at all. You already have a perfectly good Excel application open.
Originally Posted by
o0omax
how do i handle Application.Visible? Does it need to be turned True before closing the workbook?
I don't think you need to use it at all. If your concern is about the (brief) visibility of the created workbooks then Application.ScreenUpdating=False/True should handle that for you. It does here.
Originally Posted by
o0omax
Like the code currently operates, the opening of the workbooks is visible for a short time when excecuting the macro.
Application.ScreenUpdating should handle that. See code below where screenupdating is turned off at the beginning and turned back on at the end. Be aware that if the code falls over while ScreenUpdating=False you will probably need to execute Application.ScreenUpdating=True manually in order to make the application usable (this might depend on your version of Excel (which is?)
Originally Posted by
o0omax
After its finished and o open the created workbooks they appear grey. Does this have something to do with Application.Visible?
I don't know, I didn't get that here.
Your attachments have got themselves in amongst your code in the message above; I'll report the post, maybe a moderator can put that right.
Some of your lines commented-out to disable them, see also comments in the code:
Sub PasteDiagram()
Dim PP As Object
Dim PPpres As Object
Dim xlApp As Excel.Application
Dim wbSrc As Workbook
Dim wb As Workbook
Dim k As Integer
Dim path As String
path = ActiveWorkbook.path
Application.ScreenUpdating = False
'Set xlApp = CreateObject("Excel.Application")
Set PP = CreateObject("PowerPoint.Application")
Set wbSrc = ThisWorkbook
For k = 1 To 3
wbSrc.SaveCopyAs path & "\" & k & ".xlsm"
Set wb = Workbooks.Open(path & "\" & k & ".xlsm")
wb.Parent.DisplayAlerts = False
'wb.Parent.Visible = False
'hier ändere ich noch Daten des Workbooks
wb.Sheets("Diagramm").Range("A1") = "Änderungen wurden vorgenommen"
wb.Parent.DisplayAlerts = False
wb.Sheets("Sheet1").UsedRange.Clear
wb.Sheets("Sheet1").Visible = xlSheetVeryHidden
wb.Sheets("Sheet2").UsedRange.Clear
wb.Sheets("Sheet2").Visible = xlSheetVeryHidden
wb.Parent.DisplayAlerts = True
wb.Sheets("Diagramm").ChartObjects("Chart 2").Copy
Set PPpres = PP.Presentations.Open(path & "/Presentation1 (1).pptx", WithWindow:=False)
PPpres.Slides(1).Shapes.Paste
PPpres.SaveAs path & "\" & k & ".pptx"
wb.Close Savechanges:=True
PPpres.Save
PPpres.Close ' Savechanges:=True
Next
'wbSrc.Parent.Visible = True 'already visible
wbSrc.Saved = True
'wbSrc.Close 'premature/(unnecessary?) closing of this workbook (with this code in!); subsequent lines not going to be processed.
PP.Quit
Application.ScreenUpdating = True
MsgBox "fertig"
End Sub