I'm having trouble using IgnoreReadOnlyRecommended

I have Excel 2010.  The following vbscript file is executed by a scheduled task.  It opens a file to update it, save and close.  The file has the "read-only recommended" option on and my script must answer this prompt with "no" which is not the default.
Option Explicit
Dim objXL
Set objXL = WScript.CreateObject("Excel.Application")
With objXL
	.DisplayAlerts = False	
	.WorkBooks.Open FileName:="S:\Schedule\EngDates.xlsm", ReadOnlyRecommended:=False, IgnoreReadOnlyRecommended:=True
	.DisplayAlerts = TRUE
	.Visible = TRUE ' Optional
	.Run "EngDates.xlsm!UpdateDash"
	.ActiveWorkbook.Close(True)
	.Quit
End With
Set objXL = Nothing

Open in new window

I have tried several different syntax formats, with and without parentheses, and nothing has worked yet.
When I run this script, I get an error as seen in the attached file.  Does anyone see the problem with my syntax?  
Thanks!
The error that occurs when I run my script
Brennan BrauenAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ShumsExcel & VBA ExpertCommented:
Hi,

Try changing .DisplayAlert to Application.DisplayAlert
Dim objXL
Set objXL = WScript.CreateObject("Excel.Application")
With objXL
        Application.DisplayAlerts = False
        .Workbooks.Open Filename:="S:\Schedule\EngDates.xlsm", ReadOnlyRecommended:=False, IgnoreReadOnlyRecommended:=True
        Application.DisplayAlerts = True
        .Visible = True ' Optional
        .Run "EngDates.xlsm!UpdateDash"
        .ActiveWorkbook.Close (True)
        .Quit
End With
Set objXL = Nothing

Open in new window

0
Qlemo"Batchelor", Developer and EE Topic AdvisorCommented:
Shums, objXL is an Excel.Application object. Further, you cannot just use Application in VBS, you need to reference it to an object.
And it isn't causing the error anyway.
1
Qlemo"Batchelor", Developer and EE Topic AdvisorCommented:
For debugging it is a good idea to run that code in VBA, e.g. Excel or Word, applying few modifications:
Option Explicit
Sub test()
Dim objXL
Set objXL = Excel.Application
With objXL
  .DisplayAlerts = False
  .Workbooks.Open Filename:="S:\Schedule\EngDates.xlsm", ReadOnlyRecommended:=False, IgnoreReadOnlyRecommended:=True
  .DisplayAlerts = True
  .Visible = True ' Optional
  .Run "EngDates.xlsm!UpdateDash"
  .ActiveWorkbook.Close (True)
  .Quit
End With
Set objXL = Nothing
End Sub

Open in new window

That allows for giving suggestions on parameters, enables some checks and provides context sensitive help. You can also run code stepwise and/or set breakpoints, then check variable contents, ...

The issue is in ReadOnlyRecommended:=False - I suppose you meant ReadOnly:=False
0
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

Brennan BrauenAuthor Commented:
Qlemo, Thanks.  I ran step by step in VBA within Excel and it ran fine.  I did change to parameter to ReadOnly.  But when I ran my script directly it still errored out.  Must be a script syntax issue.

Shums, thanks for offering a suggestion.
0
Brennan BrauenAuthor Commented:
Found it!!  Saw this in a post:

Note: " In VBScript, arguments must be supplied in the order specified by the procedure. " which implies that naming parameters is not an option, thus they must be in the order specified, so if you have to skip a parameter, you must put the comma in to separate parameters.

Had to change my OPEN statement to:
.WorkBooks.Open "S:\Schedule\EngDates.xlsm",,False,,,,True
where the False is the ReadOnly parameter and the True is for the IgnoreReadOnlyRecommended parameter.

Thanks again!
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Brennan BrauenAuthor Commented:
I found the answer by doing further research/googling.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Office

From novice to tech pro — start learning today.