silentwolf
Well-known Member
- Joined
- May 14, 2008
- Messages
- 1,216
- Office Version
- 2016
Hi guys,
got following question regarding the taskmanager and an instant of Ms Excel after running codes.
I got a form in Access where I declared following variables
Below the code I am using..
As mentioned in bold above the code with OpenExcelFileM keeps Excel running in the Taskmanager the OpenExcelFile does clean it out
So I was wondering if someone could tell me what I would need to change in order to be able to use the globel varibles in the form module
Many thanks for your help
Albert
got following question regarding the taskmanager and an instant of Ms Excel after running codes.
I got a form in Access where I declared following variables
VBA Code:
Option Compare Database
Option Explicit
Private mappExcel As Excel.Application
Private mwkbExcel As Excel.Workbook
Private mwksExcel As Excel.Worksheet
Private mrngExcel As Excel.Range
Private mlastRow As Long
'
'
Below the code I am using..
Code:
Private Sub btnAction_Click()
Select Case btnAction.Caption
Case "Open"
If MsgBox("Datei öffnen?", vbQuestion + vbYesNo) = vbYes Then
' OpenExcelFile (Me!txtFilePath.Value) ' If I use this code the Taskmanager gets cleared
OpenExcelFileM (Me!txtFilePath.Value) 'With This code the Taskmanager keeps an instant of Excel
Else
Exit Sub
End If
Case "Update"
If MsgBox("Datei aktualisieren?", vbQuestion + vbYesNo) = vbYes Then
UpdateCSVFile (Me!txtFilePath.Value)
Else
Exit Sub
End If
End Select
End Sub
Code:
Public Function OpenExcelFile(strFilePath As String) As Boolean
Dim appExcel As Excel.Application
Dim myWorkbook As Excel.Workbook
Dim myWorkSheet As Excel.Worksheet
Set appExcel = HoleAnwendung("Excel.Application")
If appExcel Is Nothing Then
MsgBox "Kein Excel gefunden!", vbCritical, p_cstrAppTitel
Exit Function
Else
Set myWorkbook = appExcel.Workbooks.Open(strFilePath, Local:=True)
Set myWorkSheet = myWorkbook.Worksheets(1)
appExcel.Visible = True
End If
End Function
Code:
Public Function OpenExcelFileM(strFilePath As String) As Boolean
Set mappExcel = HoleAnwendung("Excel.Application")
If mappExcel Is Nothing Then
MsgBox "Kein Excel gefunden!", vbCritical, p_cstrAppTitel
Exit Function
Else
Set mwkbExcel = mappExcel.Workbooks.Open(strFilePath, Local:=True)
Set mwksExcel = mwkbExcel.Worksheets(1)
mappExcel.Visible = True
End If
End Function
As mentioned in bold above the code with OpenExcelFileM keeps Excel running in the Taskmanager the OpenExcelFile does clean it out
So I was wondering if someone could tell me what I would need to change in order to be able to use the globel varibles in the form module
Many thanks for your help
Albert