New Excel Forum

This forum has been moved to TeachExcel.com

Ask all future questions in the New Excel Forum.

ExcelKey

saving .xlam file

Macros, VBA, Excel Automation, etc.

saving .xlam file

Postby Boo » Mon Jan 18, 2016 6:54 am

Hi Excel Gurus,

I have a question related to .xlam file. We have a vba project in .xlam file, which we use always by opening directly the file (addin is not installed in excel) or by using a shortcut, which opens first excel in a separate instance and then the xlam file in it. So the problem happens exactly when opening the file through the shortcut, because when closing the file it fails to save stating, that someone else has the file open (Though it's not true!). and this happens only by one user. I have tested , in this case status of the file is ReadOnly = False. In all other cases ReadOnly = True and no error is thrown.
Can anyone explain me, why the file is always opened as ReadOnly, but in this special case (by certain user through the shortcut) it's not read-only and why it fails to save if it's not read- only? Btw. when I make changes in the code, the changes are saved, so it actually saves the changes, but then throws out the error message.

Here is the code what happens before close
Code: Select all
Public Sub Workbook_BeforeClose(Cancel As Boolean)

  AppEnableKey
 
  ' remove paste sheets
  Dim ws As Worksheet
  Application.DisplayAlerts = False
  Application.CommandBars("Ply").Enabled = True
 
  For Each ws In Worksheets
    If ws.Name <> "Sheet1" Then ws.delete
  Next
 
    MsgBox "ReadOnly" & Me.ReadOnly
 
  Me.Save ' here it fails to save
  Me.Saved = True
  Application.DisplayAlerts = False
 
End Sub
  • 0

Boo
Rookie
 
Posts: 1
Joined: Jan 18, 2016
Reputation: 0
Excel Version: Excel 2013

Return to Macros and VBA Questions

Who is online

Users browsing this forum: No registered users and 153 guests

cron