silentwolf
Active member
- Local time
- Today, 11:42
- Joined
- Jun 12, 2009
- Messages
- 644
Hi guys,
I am a little in need for some advice please.
in the above code I check if the file is already saved and if it is then exit the sub routine.
However when that is the case then excel closes alright but in the task manager Excel is still showing what do I do wrong in that above code?
Can`t seam to get it to work.
Could someone give me a hand on that one?
Many thanks in advance
I am a little in need for some advice please.
Code:
Sub UpdateAndSave(strFileName As String)
Dim appExcel As Excel.Application
Dim wkbExcel As Excel.Workbook
Dim wksExcel As Excel.Worksheet
Dim rngExcel As Excel.Range
Set appExcel = HoleAnwendung("Excel.Application")
If appExcel Is Nothing Then
MsgBox "Kein Excel gefunden!", vbCritical, p_cstrAppTitel
Else
appExcel.Visible = True
Set wkbExcel = appExcel.Workbooks.Open(strFileName, Local:=True)
Set wksExcel = wkbExcel.Worksheets(1)
Set rngExcel = Range("A1")
If rngExcel = "IBAN" Then
Dim clsVB As clsVBUpdate
Set clsVB = New clsVBUpdate
With clsVB
.FormatSpalteF (strFileName)
.CreditorUpdate (strFileName)
.DeleteBlanks (strFileName)
.ExtraLength (strFileName)
UpdatedFileName = strFileName
End With
wksExcel.Name = UpdatedFileName
End If
Set clsVB = Nothing
Dim strUpdatedFileName As String
strUpdatedFileName = PfadUpdate & "Auszug_" & wksExcel.Name
Dim objFSO As Object
Set objFSO = CreateObject("Scripting.filesystemobject")
strUpdatedFileName = strUpdatedFileName & ".xlsx"
'Check if file is saved already
If objFSO.FileExists(strUpdatedFileName) Then
MsgBox "File already saved!", vbCritical, p_cstrAppTitel
wkbExcel.Close savechanges:=False
Set objFSO = Nothing
Set wkbExcel = Nothing
Set wksExcel = Nothing
appExcel.Quit
Set appExcel = Nothing
Exit Sub
Else
With wkbExcel
.SaveAs FileName:=strUpdatedFileName, FileFormat:=xlOpenXMLWorkbook
.Close True
End With
End If
Set objFSO = Nothing
Set wkbExcel = Nothing
Set wksExcel = Nothing
appExcel.Quit
Set appExcel = Nothing
End If
End Sub
in the above code I check if the file is already saved and if it is then exit the sub routine.
However when that is the case then excel closes alright but in the task manager Excel is still showing what do I do wrong in that above code?
Can`t seam to get it to work.
Could someone give me a hand on that one?
Many thanks in advance