Full Version: Unrequested read only
UtterAccess Discussion Forums > Microsoft® Office > Microsoft Excel
DataDay
Hello,

I'm using Access to automate Excel. When the spreadsheet is opened it opens Read Only, but I have the read only argument set to false. Does anyone have semi-logical explanation or work-around for this.

Thanks

Set xll = CreateObject("Excel.application")
xll.Application.IgnoreRemoteRequests = True

Set PandLBook = xll.Workbooks.Open(Form_frmUpdateDetailPLExcel.txtFileAndPath, False, False)
KingMartin
Could be you don't have a command that closes the workbook in your code.

If you didn't set the 'xll' instance of Excel to visible, you may not notice that the workbook is still open. If you attempt to open the workbook for a second time, it opens as read-only.

Post the whole code so that we can see wink.gif

Martin
DataDay
Thanks Martin,

Here is the end bit. I'll spare you the rest of it as it is several pages worth. Actually I've been playing with it and I think the problem lies here.

PandLBook.Save
PandLBook.Close False

xll.Application.ScreenUpdating = True
xll.Application.IgnoreRemoteRequests = False
KingMartin
Hmmm,

your end bit seems to be OK. You should Set PandLBook = Nothing but it doesn't change a thing here.

Doesn't something apply from here ?
DataDay
Thanks,

I am releasing my variables, I just left it off my post. I checked you link, but nothing there seemed to help. I can open the file manually and it does not come up Read Only.

PandLBook.Save
PandLBook.Close False

xll.Application.ScreenUpdating = True
xll.Application.IgnoreRemoteRequests = False
Set shData = Nothing
Set PandLBook = Nothing
xll.Application.Quit
Set xll = Nothing
KingMartin
I am sorry but I don't know then :(

I was pretty sure you had an invisible instance of the workbook open. If you restart Windows and run the code, does the workbook open as read-only again?
KingMartin
Hello again,

two more things:

If xll is the pointer to Application object, you don't need to use xll.Application. It's the same as if you'd use

'Application.Application'

from within Excel.

But mainly, I spotted the use of IgnoreRemoteRequests. Does this mean you use DDE? But the code snippet looks rather like an automation confused.gif

Check this:
http://msdn.microsoft.com/library/en-us/of...DETerminate.asp

Martin
DataDay
Hello Martin,

I found the problem: I have a set of small function that runs before the code you've seen that does things like check if the file exist, if the file is open and if a certain query has data in it. Well, whomever wrote the part to check if the file is open (that would be me) never closes the file. So you were right when you said that the workbook may be open. Thanks.

Now why can't I just teleport you or Nate here when I need some help?

Thanks again
KingMartin
QUOTE
Now why can't I just teleport you or Nate here when I need some help?

No no, I'd be afraid.
Did you see 'THE FLY'? laugh.gif

You're welcome
frown.gif
martin
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.