File opened as READ ONLY asks Do you Want to save

B

BAC

I use the following code within a module to open excel Spreadsheets as READ
ONLY to update an Access database


Set fs = CreateObject("Scripting.FileSystemObject")
Set fp = fs.GetFolder("\\Shared\Write-ups\")
Set ff = fp.files

fil_2_use = GetOpenFile(fp, "RAF List") (This Function is code originally
written by Ken Getz. It allows user to select file to be read)

If IsNull(fil_2_use) Or fil_2_use = "" Then Exit Sub

Set f = fs.GetFile(fil_2_use)

With xcl.Application
.Workbooks.Open fil_2_use, UpdateLinks:=False, ReadOnly:=True
Set wrkbk = xcl.ActiveWorkbook
.......
Here is Code to Read Worksheets......

wrkbk.Saved = True
wrkbk.Close

But the sub stops with dialog box "Do you want to save changes to ..."

No changes are made to the spreadsheets, but I do unhide a sheet (If I don't
I get a subscript out of range error when I try to read from it). There are
no Before Close events in the spreadsheets, and we have ensured no one else
had the spreadsheet open during our saves.

I cannot find the answer on the KB.

Why is it asking me to save changes when i've opened it as read only and
added the wrkbk.saved = true before closing
 
R

Ralph

rather than wrkbk.save =true

try:

xcl.displayalerts=false
wrkbk.close
xcl.displayalerts=true
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top