Torchwood
03-10-2014, 06:00 AM
Here's an odd behaviour that I've no idea how to fix ...
(Using Excel 2010 32-bit on Windows 7)
Setup:
+ Create two Excel files on desktop: Master.xlsm and Slave.xlsm
+ Master.xlsm contains two tabs: Sheet1 and Sheet2. Add a simple Command Button from the Forms control menu onto Sheet2, and link it to the following Macro (in a standard code mode):
Public Sub Main()
Dim oMaster As Workbook
Dim oSlave As Workbook
Dim sSlaveName As String
sSlaveName = "C:\Users\jwhite31\Desktop\Slave.xlsb"
Set oMaster = ActiveWorkbook
Set oSlave = Application.Workbooks.Open(sSlaveName, 0, True)
oMaster.Sheets("Sheet1").Delete
oSlave.Close
Set oSlave = Nothing
Set oMaster = Nothing
End Sub
+ Slave.xlsm is just an empty worksheet with a couple of empty tabs; nothing else
Then, press the command button to run the code; all works as expected; Sheet1 has been deleted from the Master file. Now try to save Master.xlsm - on my PC this crashes every time!
What is going on? I hope someone has some ideas ...
(Using Excel 2010 32-bit on Windows 7)
Setup:
+ Create two Excel files on desktop: Master.xlsm and Slave.xlsm
+ Master.xlsm contains two tabs: Sheet1 and Sheet2. Add a simple Command Button from the Forms control menu onto Sheet2, and link it to the following Macro (in a standard code mode):
Public Sub Main()
Dim oMaster As Workbook
Dim oSlave As Workbook
Dim sSlaveName As String
sSlaveName = "C:\Users\jwhite31\Desktop\Slave.xlsb"
Set oMaster = ActiveWorkbook
Set oSlave = Application.Workbooks.Open(sSlaveName, 0, True)
oMaster.Sheets("Sheet1").Delete
oSlave.Close
Set oSlave = Nothing
Set oMaster = Nothing
End Sub
+ Slave.xlsm is just an empty worksheet with a couple of empty tabs; nothing else
Then, press the command button to run the code; all works as expected; Sheet1 has been deleted from the Master file. Now try to save Master.xlsm - on my PC this crashes every time!
What is going on? I hope someone has some ideas ...