Visual Basic Development Bookmark and Share   
 Home > Visual Basic Interop and Upgrade > Excel App written in 2003 hangs when run in 2007
 

Excel App written in 2003 hangs when run in 2007

I have an Excel application that I wrote using Excel 2003. The process begins by opening a file to be processed, call that File A. Then it opens File B, selects a worksheet, copies that worksheet into File A, renames the sheet,and goes on. When I ran the process under Excel 2007, it would hang somewhere between the 'copy the sheet' step and the 'rename the sheet' step without giving me a run-time error.

In the process of troubleshooting, I stepped through the code, and it ran all the way through without error. I went back and ran it normally, and got the hang again.

I went back into the code and inserted Message Boxes just after the 'copy' step and just after the 'rename' step. Again, except for pausing for operator response on the message boxes, the code ran normally.

My last experiment was to remove the message boxes and insert a
For I = 1 to 10
Next
between the 'copy' step and the 'rename' step. This also allows the system to function normally.

The following code hangs:

    Workbooks.Open Filename:=ToolSetPath & "\TrnRecordsWH.xlsm"
    RecordsWorkbook = ActiveWorkbook.Name
    Sheets("Sheet1").Select
    Sheets("Sheet1").Copy After:=Workbooks(AnalysisWorkbook).Sheets(NumSheets)
    Sheets("Sheet1").Select
    Sheets("Sheet1").Name = "EmpTrnRecordsWH"
    Workbooks(RecordsWorkbook).Close SaveChanges:=False
The following code works:
    Workbooks.Open Filename:=ToolSetPath & "\TrnRecordsWH.xlsm"
    RecordsWorkbook = ActiveWorkbook.Name
    Sheets("Sheet1").Select
    Sheets("Sheet1").Copy After:=Workbooks(AnalysisWorkbook).Sheets(NumSheets)
For I = 1 to 10
Next
Sheets("Sheet1").Select Sheets("Sheet1").Name = "EmpTrnRecordsWH" Workbooks(RecordsWorkbook).Close SaveChanges:=False
  • Changed TypeJohn91311 Thursday, October 29, 2009 8:34 PM
  •  
John91311  Thursday, October 29, 2009 8:31 PM
I would recommend posting your question to the VBA forum:

http://social.msdn.microsoft.com/Forums/en-US/isvvba/threads


Paul ~~~~ Microsoft MVP (Visual Basic)
Paul P Clement IV  Friday, October 30, 2009 4:36 PM
I would recommend posting your question to the VBA forum:

http://social.msdn.microsoft.com/Forums/en-US/isvvba/threads


Paul ~~~~ Microsoft MVP (Visual Basic)
Paul P Clement IV  Friday, October 30, 2009 4:36 PM

You can use google to search for other answers

Custom Search

More Threads

• COM+ run as account query
• Excel macros to VB 2005
• Help with Object reference not set to an instance of an object.
• Passing an array byref from VBA to VB.net
• How to Open a VB.Net Form (like an mdi child form) from a VB6 MDI Form
• Textbox won't update using method triggered event
• Message box not working in VB.Net when invoked inside ticker event of timer
• Problem using Interop UserControl
• Visual Basic 5.0 To Visual Basic 9.0
• Flexgrid, DataGridView and sorting