elyfrank
10-26-2017, 03:56 PM
Hi guys,
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 vbs 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 vbs 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
objExcel.Application.Quit
Set objExcel = Nothing
And this is part of the vba module:
Sub Macro1()
Application.Visible = False
UserForm1.Show
End Sub
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
ThisWorkbook.Close savechanges = False
Application.Quit
End
End If
End Sub
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 vbs 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 vbs 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
objExcel.Application.Quit
Set objExcel = Nothing
And this is part of the vba module:
Sub Macro1()
Application.Visible = False
UserForm1.Show
End Sub
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
ThisWorkbook.Close savechanges = False
Application.Quit
End
End If
End Sub