Windows Script Host

Jasonrito1

New Member
Joined
Feb 6, 2019
Messages
6
Hello everyone,

I made a Macro and it uses many user forms depending on the buttons you clic. The point is that I use a .vbs script to run it without having to open the excel workbook. It displays the login userform and everything works perfectly. The problem is that after you are done using the macro and click the button to exit an error message is displayed. I dont know why since everything works perfectly. I already tried moving the workbook to another location but still remains the same message.

It displays that the error is in line 2 char 1. Line 2 is the one that has the pathfile but I dont see any problem with it.

Probably is something wrong in the macro code?

Any help?

Thanks!
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Sorry here it is:

The message:

Script: C:\USers\Z624170\Desktop\Actividades Ingeniería.vbs
Line: 3
Char: 1
Error: Unknown runtime error
Code: 800A9C68
Source: Microsoft VBScript runtime error


The code:

Set objExcel = CreateObject("Excel.Application")
objExcel.Application.Run "'M:\Team\CC14707\Common\0010.- Torque Converter\0020 Process enginnering\0110 Critical follow-up activities\Registro Actividades de Ingenieria.xlsm'!Module1.Abrir"
objExcel.DisplayAlerts = False
objExcel.Application.Quit
Set objExcel = Nothing
 
Upvote 0
Last edited:
Upvote 0
I just did the same as you with the xlsm displaying a Msgbox and there was no error message.

Regarding your question, yes I am quitting Excel in the Macro with two different buttons located in different userforms. The first one is on the "login" user form where you can access or cancel and it should close the Excel workbook. The second one is on the "menu" user form once you've succesfully accessed the first user form.

Ill take a look to that method and see if it works
 
Upvote 0
I tried the method you suggested and the Line where the error is supposed to be changed. Here is the new code:

Option Explicit
Dim xlApp, xlBook
Set xlApp = CreateObject("Excel.Application")
set xlBook = xlApp.Workbooks.Open("M:\Team\CC14707\Common\0010.- Torque Converter\0020 Process enginnering\0110 Critical follow-up activities\Registro Actividades de Ingenieria.xlsm",0, False)
xlApp.Run "Module1.Abrir" Error is being detected on this line. Any suggestions? The macro runs ok if you run it from Excel and the "Module1.Abrir" all it does is a Userform.show.
xlBook.Close True
xlApp.Quit
set xlBook = Nothing
Set xlApp = Nothing

Module1.Abrir content

Sub Abrir()
Revision.Show
End Sub
 
Upvote 0
I am pretty sure that link did not reference the module?, just the macro, just as you would from Excel.?
 
Upvote 0
No I did it using "Thisworkbook.close" which is located in the "LogIn" and the "Menu" userforms and after reading your comment I set that command as a comment and the message was gone. Do you have an idea why would that happen?
 
Upvote 0
Well I would have said if you close the workbook, then do not attempt to close it in the vbscript.?
Without testing, that is just a guess, but again would not be the error you mentioned initially.?
 
Upvote 0
I guess that was it. I was attempting to close a workbook that was already closed therefore the errror message.

Thank you!
 
Upvote 0

Forum statistics

Threads
1,223,898
Messages
6,175,272
Members
452,628
Latest member
dd2

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top