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
 

Some videos you may like

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.

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 ?
 

Watch MrExcel Video

Forum statistics

Threads
1,118,760
Messages
5,574,088
Members
412,566
Latest member
TexasTony
Top