I run this script on the server (remote control via terminal services).
So the path is OK
Thks
Hilaire
Main Topics
Browse All TopicsHi all,
The following script works like a charm on my workstation
<dummy_script.vbs>
Dim objExcel
Dim objWorkBook
Set objExcel = CreateObject("EXCEL.APPLIC
Set objWorkBook = objExcel.Workbooks.Open("C
objWorkBook.SaveAs ("C:\test\test2.xls")
objWorkBook.Close True
Set objWorkBook = Nothing
Set objExcel = Nothing
</dummy_script.vbs>
It used to work on a server that generates XL files on the fly and sends them by email upon request in an intranet application.
The code above is just a sample, the actual app is VB6 and involves DB access, running macros, ...
Trying to narrow the scope I found out that the simple script above does not work any more on the server.
The test.xls file is the most simple XL file ever, and the path is OK
The NT account I use definitely has write permissions on the target directory, and test2.xls does not exist when I run the script.
Excel is installed on the server and works normally when used as a client app.
But it seems to fail miserabily when used as an activeX object. The script above says it can't find the file, but both the directory and the fiel definitely exist on the server.
I also checked that the script does not fail due to a ghost/remanant excel.exe process in memory,
using windows toolkit (tlist, kill, ...) : no ghost excel.exe ...
Any ideas what could break / alter the way excel works when used as an activeX object from another App/Script ?
Any comments welcome
Hilaire
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Hi Hilaire,
Looking at your code are you trying to run this from a web page. Either ASP, HTM or any of the others? Especially ASP, P2P or another server-side web page. Because if so then you are going to fail with that code as it doesn't take into account who is logged in or any of their permissions. So if it is serverside page then you need to firstly use the full UNC path (in the format \\server\share\path\file.e
Cheers,
MalicUK.
Hilaire, here is the javascript I used.
<script language="javascript">
function openExcel(strFileName) {
var yourAddress = "//server/share/folder/sub
openExcelDocPath(yourAddre
}
function openExcelDocPath(strLocati
var objExcel;
objExcel = new ActiveXObject("Excel.Appli
objExcel.Visible = true;
objExcel.Workbooks.Open(st
}
</script>
Then I called it in this case by a hyperlink using:
<P><A HREF="#" onClick="openExcel('154.xl
Although it can of course be called anywhere where javascript can be called using:
openExcel('myfile.xls');
Thks MalicUK,
this code is (tranlated from VB6 to VBS) part of a VB6 server component that runs as a service on the server, "listens" for new jobs from a database-hosted queue and generates XL files accordingly.
The service is run using a special account that has sufficient rights on the target directory.
Eg I can create a file manually in the target directory when connected as this user on the server.
I provided sample code to narrow the scope a show a simple operation that used to work, and does not work anymore since yesterday (as a side not, we changed the security level of macros/VBA in excel from "average" to "low" cause a company did not send us the latest security certificates).
Maybe there's a prompt or a new server settings that prevents Excel to run in silent mode (The app runs as a NT service, so I don't want excel to show)
Hilaire
OK, just majorly confused there.
Right have you tried dim-ing objExcel and objWorkbook as Objects rather than variables? I don't know that this is the problem but I just am trying anything!
Dim objExcel As Object
Dim objWorkBook As Object
Set objExcel = CreateObject("EXCEL.APPLIC
Set objWorkBook = objExcel.Workbooks.Open("C
objWorkBook.SaveAs ("C:\test\test2.xls")
objWorkBook.Close True
Set objWorkBook = Nothing
Set objExcel = Nothing
>>OK, just majorly confused there<<
Sorry I'm not a native english-speaker so my comments happen to be far from crystal-clear ;-)
in VB6 I tried both fully qualified object types (excel.application, excel.workbook) and generic object.
sample code is VBS, so no datatype accepted.
In fact I think the question could be shortened as follows :
- yesterday I could use Excel as an ActiveX object in my VB6/VBS code
- today it doesn't work any more
- meanwhile I just changed security level for macros from "average" to "low" (reverting to "average" doesn't solve the prb)
- excel is still OK when used as a client app
Is there a way to fix it whithout re-installing Excel ?
instead of re-installing Excel you might try the startup switches:
http://support.microsoft.c
/regserver Forces Excel to register itself and then quit. Use this
switch when you want Excel to rewrite all its
registry keys and reassociate itself with Excel files,
such as workbooks, charts, and so on.
Example: /regserver
Thanks roos01, I didn't remember this
I finally got it to work in VBS using /unregserver and /regserver,
my VB6 still failed but I noticed that the excel version on the server had been updated.
my VB6 code used
dim objwkb as Excel.Workbook
I got it to work again by using object datatype + late binding
dim objwkb as object
set objwkb = createobject("Excel.Workbo
Business Accounts
Answer for Membership
by: roos01Posted on 2004-10-19 at 01:26:18ID: 12345375
Did you try to work with the IP addres of the server instead the C:\ prompt?
I can imagine that some stations are looking at their own C-drive
regards,
Jeroen