ChuckRobert
Board Regular
- Joined
- Feb 26, 2009
- Messages
- 64
I have a series of linked workbooks, initially built with Excel 2003. After converting to Office 2010 I saved them as .xlsm workbooks, and updated all links. Now, I am having a problem with a workbook close macro that never gave me a problem while in Excel 2003. I have tried 3 variations of closing the workbook with a macro assigned button, but the problem remains with all of them:<?xml:namespace prefix = o ns = "urn:schemas-microsoft-comfficeffice" /><o></o>
<o></o>
Specifically - <o></o>
1. If I only have one workbook open, I can run the workbook.close macro button all day without failure. <o></o>
2. If I have more than 1 workbook open, and click the X in the upper right corner to close a workbook, the workbook closes fine. <o></o>
3. However, if I have more than 1 workbook open, and click the workbook.close macro button to close a workbook, about 50 percent of the time I get the following error message:<o></o>
<o></o>
“Microsoft Excel has encountered a problem and needs to close. We are sorry for the inconvenience. The information you were working on might be lost. Microsoft Excel can try to recover it for you.” Then a check box displays to recover my work and restart Microsoft Excel. <o></o>
<o></o>
I have tried the 3 following variations to the workbook.close macro, but all provide the same results. <o></o>
I’ve looked extensively, but have been unable to determine what is causing the error. Any suggestions would be greatly appreciated. <o></o>
<o></o>
Specifically - <o></o>
1. If I only have one workbook open, I can run the workbook.close macro button all day without failure. <o></o>
2. If I have more than 1 workbook open, and click the X in the upper right corner to close a workbook, the workbook closes fine. <o></o>
3. However, if I have more than 1 workbook open, and click the workbook.close macro button to close a workbook, about 50 percent of the time I get the following error message:<o></o>
<o></o>
“Microsoft Excel has encountered a problem and needs to close. We are sorry for the inconvenience. The information you were working on might be lost. Microsoft Excel can try to recover it for you.” Then a check box displays to recover my work and restart Microsoft Excel. <o></o>
<o></o>
I have tried the 3 following variations to the workbook.close macro, but all provide the same results. <o></o>
Code:
[SIZE=3][FONT=Times New Roman]Sub SaveAndCloseWorkbook()<o:p></o:p>[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]ActiveWorkbook.Close True<o:p></o:p>[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]End Sub<o:p></o:p>[/FONT][/SIZE]
Code:
[SIZE=3][FONT=Times New Roman]Sub SaveAndCloseWorkbook()<o:p></o:p>[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]ThisWorkbook.Close savechanges:=True<o:p></o:p>[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]End Sub<o:p></o:p>[/FONT][/SIZE]
Code:
[SIZE=3][FONT=Times New Roman]Sub SaveAndCloseWorkbook()<o:p></o:p>[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]Dim wbName As String<o:p></o:p>[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]wbName = ThisWorkbook.Name<o:p></o:p>[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]Workbooks(wbName).Close savechanges:=True<o:p></o:p>[/FONT][/SIZE]
[SIZE=3][FONT=Times New Roman]End Sub<o:p></o:p>[/FONT][/SIZE]
I’ve looked extensively, but have been unable to determine what is causing the error. Any suggestions would be greatly appreciated. <o></o>