code von Nepumuk - Excel Instanz schützen
16.04.2016 21:53:44
Nepumuk
ich habe hier im Archiv diesen Code aus Nepumuks Trickkiste gefunden.
https://www.herber.de/forum/archiv/344to348/347147_ExcelInstanz_schuetzen.html
Da der Code aber von 2003 ist, frage ich mich ob der code noch ein update/Änderung benötigt.
Ich kann nichts feststellen. funktioniert mit xl2013 noch genauso gut.
Ich kenne mich nur mit Klassenmodulen nicht aus.
beim öffnen einer anderen datei vom Desktop aus wird diese auch in einer neuen Instanz geladen. passt also. Kann man noch was mit Application.ScreenUpdating = False machen? ein kurzes flackern ist zu sehen beim schließen bzw. beim wieder öffnen der zweiten Datei.
Diese Arbeitsmappe
Option Explicit
Private Sub Workbook_Open()
Set newClas.App = Application
End Sub
Modul
Option Explicit
Public newClas As New clsApp
Klassenmodul clsApp
Option Explicit
Public WithEvents App As Application
Private Sub App_WorkbookOpen(ByVal Wb As Workbook)
Dim myApplication As New Excel.Application, strWorkbooksNamePfad
If Wb.FullName ThisWorkbook.FullName Then
strWorkbooksNamePfad = Wb.FullName
Workbooks(Wb.Name).Close False
myApplication.Visible = True
myApplication.Workbooks.Open (strWorkbooksNamePfad)
End If
Set myApplication = Nothing
End Sub