Ending Excel.exe in Task Manager using VBA

Madingo

New Member
Joined
Mar 4, 2002
Messages
26
I have a client running a macro using excel 2003 over a terminal server. I am running into a problem where I can't save an excel sheet as a csv because it says that the file is being used by another user. I only have this problem over the term server. I have other people running the macro from their desktops without incident. I then need to go into task manager and end the excel.exe process and re-run---which then it works. Does anyone have any idea why I would have this problem over the term server and is there a way I can test to see if excel is open--and if it is close it prior to my activeworkbook.saveas line. Below are the lines where I am saving the xls file as a csv. I get the error on the activeworkbook.saveas

Workbooks(ImportMasterName & ".xls").Activate

ActiveWorkbook.SaveAs Filename:=ImportPath & ImportMasterName & ".csv", FileFormat:=xlCSV, CreateBackup:=False

Workbooks(ImportMasterName & ".csv").Close


like i said it works fine but only over the term server do i have the problem. Thanks for any help.

bill mahoney
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".

BrianB

Well-known Member
Joined
Feb 17, 2003
Messages
8,127
1. You might be able to save the file as .xls with another name and then save the *copy* as .csv
2. I can understand you might get an error because .csv only allows a single sheet. If multiple sheets you presumably have the correct sheet active. Normally we get a warning message, and it may be this that gives the problem. Might try DisplayAlerts=False.
3. I have trouble understanding that you have an Excel macro running and need to check if Excel is running. Are you running a separate instance of Excel ?
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,020
Messages
5,834,989
Members
430,331
Latest member
Syed Yasir Hannan

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
Top