Reputation: 45
We have tried to fix these problem for a couple of days and we posted on another forums but still no answer, may be you guys can help us here.
I am having a problem with excel running after the Userform is closed, I think what I have supposed to end the application but it doesn't, it keeps excel running in the background and I have to end the process with task manager. I created a vba file to copy a file to the temp folder and run a macro which opens excel and the userform. Any help is appreciate it.
This is the vba script that copy and opens the macro:
Dim FSO
Set FSO = CreateObject("Scripting.FileSystemObject")
FSO.CopyFile "C:\pdfv6.xlsm", "C:\Windows\Temp\"
Set objExcel = CreateObject("Excel.Application")
objExcel.Application.Run "'C:\Windows\Temp\pdfv6.xlsm'!module1.macro1"
objExcel.DisplayAlerts = False
Set objExcel = Nothing
objExcel.Application.Quit
And this is part of the vba module:
Sub Macro1()
Application.Visible = False
UserForm1.Show
End Sub
Set objExcel = Nothing
And this is the Sub that deals with closing the Userform and the application.
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If CloseMode = 0 Then
Unload Me
ThisWorkbook.Close savechanges = False
Application.Quit
End
End If
End Sub
Upvotes: 0
Views: 2247
Reputation: 45
I found the problem. I was using Application.Quit twice Once in the vbs script and then when I was closing the form. I got rid of the one in the vbs script and everything is fine now. thank you for your help.
Upvotes: 2