Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default Unable to run excel via vbscript

We are using cygwin (which provides Unix-like functionality on Windows) so that we can not only use Unix-like tools but also use the cron scheduling facility. We need to run some Excel programs and are using vbscript to do this. We have this running on a WinXP machine but are having trouble running on a Win7 machine, but we don't think it is a Win7 problem.

Here's the script to run a simple test excel program:

Dim xlApp
Dim xlWb
Set xlApp = CreateObject("Excel.application")
xlApp.Visible = True
Set xlWb = xlApp.workbooks.Open("c:\Shared\Prospect\Bin\TestE xcel.xls")
xlApp.Quit
Set xlWb = Nothing
Set xlApp = Nothing

Here's how we run this test script from a terminal command prompt:

c:/Windows/System32/wscript.exe 'c:\cygwin64\home\<cygwinLogin\tst.vbs'

This runs fine from a command line prompt but hangs when run as a cron job. We have trapped the error message we get when the workbooks.Open is executed and get this:

Microsoft Office Excel cannot access the file 'c:\Shared\Prospect\Bin\TestExcel.xls'. There are several possible reasons:

–’ The file name or path does not exist.
–’ The file is being used by another program.
–’ The workbook you are trying to save has the same name as a currently open workbook.

We don't believe any of these possible reasons apply. In particular, since it looked like this could be a permission issue, we changed the vbscript to simply copy the TestExcel.xls file and that works fine.

This hanging also happens if we create a new spreadsheet and try to save it (and this works fine from a command prompt). So we can run excel programs from a cron job as long as we don't open an excel program or save a spreadsheet, which means it is useless.

We also have a couple of other Win7 PCs. This problem happens on 2 of the 3 Win7 PCs but works on one of the Win7 PCs. All 3 PCs are running Excel 2007 SP3.

Anybody have any idea what could be going on here? We only have this cron job problem when running an excel program via vbscript. We haven't had any cron job problems with other non-excel scripts.

Denis
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,182
Default Unable to run excel via vbscript

It's likely to have something to do with cygwin and using the cron
scheduling utility. The VBScript part (saved as a .vbs file) works fine
on this Win7 Pro machine and so precludes this isn't where the problem
lies. I suspect the Filename string gets modified somehow by the cron
utility such that Excel can't interpret it correctly.

FWIW:
Note that my default Excel version is 2010 on this machine, but I can
change that to whatever version you have for testing version-specific
issues if you state what version you're working with.

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default Unable to run excel via vbscript

On Thursday, June 11, 2015 at 11:14:28 AM UTC-5, GS wrote:
It's likely to have something to do with cygwin and using the cron
scheduling utility. The VBScript part (saved as a .vbs file) works fine
on this Win7 Pro machine and so precludes this isn't where the problem
lies. I suspect the Filename string gets modified somehow by the cron
utility such that Excel can't interpret it correctly.

FWIW:
Note that my default Excel version is 2010 on this machine, but I can
change that to whatever version you have for testing version-specific
issues if you state what version you're working with.


Here are the Excel versions we are using on these 3 Win7 PCs:

Microsoft Office Excel 2007 (12.0.6718.5000) SP3 MSO (12.0.6607.1000)
Microsoft Office Excel 2007 (12.0.6718.5000) SP3 MSO (12.0.6721.5000)
Microsoft Office Excel 2007 (12.0.6718.5000) SP3 MSO (12.0.6721.5000)

The first 2 versions are on the 2 Win7 PCs that fail and the last version is on the Win7 PC that succeeds. Since the 2nd and 3rd versions are identical, that would seem to rule out this being an Excel problem since one succeeds and the other fails.

Here is the vbscript that was created to just copy the file that excel fails to open. This was done in an attempt to see whether there was a permission issue when run from the cron. If cron was mangling the filename, it seems like it would mangled it both for excel and for copying.

dim filesys
set filesys=CreateObject("Scripting.FileSystemObject")
If filesys.FileExists("c:\Shared\Prospect\Bin\TestExc el.xls") Then
filesys.CopyFile "c:\Shared\Prospect\Bin\TestExcel.xls", "c:\cygwin64\home\<cygwinLogin\"
Else
WScript.Echo "file does not exist"
End If

I wonder if the credentials/permissions inherited by excel from cron could be wrong. Is there any way to check these credentials? That would seem to be the one difference between excel opening this TestExcel.xls file versus just copying it. Starting up Excel is creating a separate process.

Denis
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,182
Default Unable to run excel via vbscript

On Thursday, June 11, 2015 at 11:14:28 AM UTC-5, GS wrote:
It's likely to have something to do with cygwin and using the cron
scheduling utility. The VBScript part (saved as a .vbs file) works
fine on this Win7 Pro machine and so precludes this isn't where the
problem lies. I suspect the Filename string gets modified somehow
by the cron utility such that Excel can't interpret it correctly.

FWIW:
Note that my default Excel version is 2010 on this machine, but I
can change that to whatever version you have for testing
version-specific issues if you state what version you're working
with.


Here are the Excel versions we are using on these 3 Win7 PCs:

Microsoft Office Excel 2007 (12.0.6718.5000) SP3 MSO (12.0.6607.1000)
Microsoft Office Excel 2007 (12.0.6718.5000) SP3 MSO (12.0.6721.5000)
Microsoft Office Excel 2007 (12.0.6718.5000) SP3 MSO (12.0.6721.5000)

The first 2 versions are on the 2 Win7 PCs that fail and the last
version is on the Win7 PC that succeeds. Since the 2nd and 3rd
versions are identical, that would seem to rule out this being an
Excel problem since one succeeds and the other fails.

Here is the vbscript that was created to just copy the file that
excel fails to open. This was done in an attempt to see whether
there was a permission issue when run from the cron. If cron was
mangling the filename, it seems like it would mangled it both for
excel and for copying.

dim filesys
set filesys=CreateObject("Scripting.FileSystemObject")
If filesys.FileExists("c:\Shared\Prospect\Bin\TestExc el.xls") Then
filesys.CopyFile "c:\Shared\Prospect\Bin\TestExcel.xls",
"c:\cygwin64\home\<cygwinLogin\" Else
WScript.Echo "file does not exist"
End If

I wonder if the credentials/permissions inherited by excel from cron
could be wrong. Is there any way to check these credentials? That
would seem to be the one difference between excel opening this
TestExcel.xls file versus just copying it. Starting up Excel is
creating a separate process.

Denis


Excel doesn't inherent credentials/permissions! These are file system
properties. On the errant machine there must be some anomoly causing
its Excel install to behave this way. I'd be inclined to run 'Repair'
in Control Panel Programs and Features before going any further.
Also, try this VBScript and see what happens...

Dim xlApp
Dim xlWb
Set xlApp = CreateObject("Excel.application")
xlApp.Visible = True
Set xlWb = xlApp.workbooks.Open("C:\Shared\Prospect\Bin\TestE xcel.xls")
Set xlWb = Nothing
Set xlApp = Nothing

...and if it works then the problem lies with either cron's processing
on that system -OR- that system's handling of the cron process.

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default Unable to run excel via vbscript

On Thursday, June 11, 2015 at 9:11:52 PM UTC-5, GS wrote:

Excel doesn't inherent credentials/permissions! These are file system
properties. On the errant machine there must be some anomoly causing
its Excel install to behave this way. I'd be inclined to run 'Repair'
in Control Panel Programs and Features before going any further.
Also, try this VBScript and see what happens...

Dim xlApp
Dim xlWb
Set xlApp = CreateObject("Excel.application")
xlApp.Visible = True
Set xlWb = xlApp.workbooks.Open("C:\Shared\Prospect\Bin\TestE xcel.xls")
Set xlWb = Nothing
Set xlApp = Nothing

..and if it works then the problem lies with either cron's processing
on that system -OR- that system's handling of the cron process.


Changing the filename on the workbooks.Open as suggested above didn't make any difference.

I looked for the repair option under Control Panel/Program Features but didn't find one. However, I can't imagine this is the issue. On the other Win7 PC that also has this problem I had re-installed Excel a while back and that didn't make any difference. This version of Excel was the same version as the one on the Win7 PC that does work.

Denis


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,182
Default Unable to run excel via vbscript

On Thursday, June 11, 2015 at 9:11:52 PM UTC-5, GS wrote:

Excel doesn't inherent credentials/permissions! These are file
system properties. On the errant machine there must be some anomoly
causing its Excel install to behave this way. I'd be inclined to
run 'Repair' in Control Panel Programs and Features before going
any further. Also, try this VBScript and see what happens...

Dim xlApp
Dim xlWb
Set xlApp = CreateObject("Excel.application")
xlApp.Visible = True
Set xlWb =
xlApp.workbooks.Open("C:\Shared\Prospect\Bin\TestE xcel.xls") Set
xlWb = Nothing Set xlApp = Nothing

..and if it works then the problem lies with either cron's
processing on that system -OR- that system's handling of the cron
process.


Changing the filename on the workbooks.Open as suggested above didn't
make any difference.


I copy/pasted the filename from your original post. Don't know what you
mean by "changing the filename"!

Are you saying the VBScript didn't work with your correct file string?

I looked for the repair option under Control Panel/Program Features
but didn't find one. However, I can't imagine this is the issue. On
the other Win7 PC that also has this problem I had re-installed Excel
a while back and that didn't make any difference. This version of
Excel was the same version as the one on the Win7 PC that does work.

Denis


--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default Unable to run excel via vbscript

On Friday, June 12, 2015 at 2:40:18 PM UTC-5, GS wrote:
I copy/pasted the filename from your original post. Don't know what you
mean by "changing the filename"!

Are you saying the VBScript didn't work with your correct file string?


From what I saw, what you copy/pasted changed c: to C: and that's what I meant by changing the filename. With this change, the vbscript behaved exactly the same way as before - excel hung.

Denis
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,182
Default Unable to run excel via vbscript

On Friday, June 12, 2015 at 2:40:18 PM UTC-5, GS wrote:
I copy/pasted the filename from your original post. Don't know what
you mean by "changing the filename"!

Are you saying the VBScript didn't work with your correct file
string?


From what I saw, what you copy/pasted changed c: to C: and that's
what I meant by changing the filename. With this change, the
vbscript behaved exactly the same way as before - excel hung.

Denis


Ah! I was testing with an existing file on this machine. I only
copy/pasted your folder\file string to the right of my "C:\" part.


<snip
"I looked for the repair option under Control Panel/Program Features
but didn't find one."

You have to select the program in the list, click 'Change', then choose
'Repair' in its setup dialog.


<snip
"On the other Win7 PC that also has this problem I had re-installed
Excel a while back and that didn't make any difference. This version
of Excel was the same version as the one on the Win7 PC that does
work."

I suspect then, that it's an OS issue with cron because the VBScript
works for me on XP/Win7 Pro/Win8.1 running Office versions 9 thru 14!

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Set a reference to Microsoft VBScript Regular Expressions(vbscript.dll) cate Excel Programming 2 December 1st 09 03:07 PM
Run VBScript from Excel Amy M Excel Discussion (Misc queries) 4 September 19th 08 09:07 PM
vbscript and Excel HSalim[MVP] Excel Programming 8 April 12th 07 08:02 PM
Excel & VBScript Bill Ebbing Excel Programming 7 September 8th 05 06:27 PM
Using excel through vbscript ashtom1 Excel Programming 6 July 6th 05 02:55 PM


All times are GMT +1. The time now is 10:35 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"