0

I am trying to switch a Excel VBA macro from Windows XP to Windows 7. Both of the Windows versions are 32-bit operating systems. My Windows 7 version is Enterprise edition.

The VBA code works fine on Windows XP. When I have tried to run the code on Windows 7, it crashes and reports no error description.

I have registered msinet.ocx, which appears to be required for Microsoft Internet Transfer Control 6.0. I have also tried to fix security issues by adding the additional com components tabctl32, comctl332/232/32 and comdlg32, all of which are ocx files. However, nothing changes - my code still fails on Windows 7.

Once msinet was unregistered, Excel VBA opens my Workbook, reports the missing reference msinet and does not work at all. How do I resolve this issue?

StayOnTarget
  • 11,743
  • 10
  • 52
  • 81
Gionata
  • 1,513
  • 2
  • 11
  • 11
  • 1
    Have you tried to compile your code on the windows 7 machine? – assylias Jul 18 '12 at 11:02
  • Yes, I've tried. But there's missing reference and no way to fix it. I like to know if there's some compatibility issues in Win7/xp VBA code. – Gionata Jul 18 '12 at 11:12
  • Does it crashes on Opening the workbook or while executing some procedure? Have you check any API call for syntaxis/parameters changes? – CaBieberach Jul 18 '12 at 13:03
  • The issue is opening the workbook. I suppose there is no syntaxis error . The vba code runs on WinXp os as well I suppose no syntaxis changes occurs between XP and 7. – Gionata Jul 18 '12 at 14:17

3 Answers3

2

Awkward. Open the sheet in an Excel session with Macro Security set to high or medium, and reply 'No' to the dialogue about enabling VBA macros in the sheet.

If it opens, you should still be able to view the project, and this might show an obvious missing reference or an error if you attempt to compile it.

Next: save the workbook as html and close Excel. Clear the temp folder, restart excel, open the html file and save it back into Excel format. If you're lucky, all the legacy objects and references will be cleared out and replaced by versions compatible with your new OS.

This works about half the time.

Nigel Heffernan
  • 4,636
  • 37
  • 41
  • I've tried your solution. No positive feedback. There are two facts confusing me. If msinet.ocx not installed, the reference lists obviously marks the reference as missing but Excel does not crashes as well as application does not work. Once msinet.ocx is installed and activeX on, Excel crashes. There is no missing reference. I suppose msinet is not compatible at all with Win7... is it right? – Gionata Jul 19 '12 at 10:34
  • You have actually found something out here: standard techniques for cleaning-up corrupted Excel files don't change the observed behaviour. So you've eliminated one possible source of the problem: it's not your file, it's msinet.ocx - and I would suggest that your next investigation is to strip out all instances and references to that ocx, and see if the file is stabilised. – Nigel Heffernan Aug 23 '12 at 00:54
1

The system not crashing when msinet.ocx is not registered doesnt necessary means that it is the problem.

If you have a call to that library (msinet.ocx) in any procedure inside of or called from the ThisWorkbook module and you have that library unregistered, then when the file opens and tries to run the On open macro the module will not compile and therefore wont run the line of code that makes it crash. (I am only guessing that this might be your case.)

Try to find out which exact call makes your system crash.

  1. Let msinet.ocx registered.
  2. Open the file without activating the macros.
  3. Then manually run Step by Step (F8) through the opening code of your file ( Private Sub Workbook_Open() )

Eventually you will reach the exact line of code that makes your system crash. Whit that information you will be able to get more help.

NOTE:

To open the file without activating the macros you can use one of the following methods:

  • Press and keep pressed the Shift key after you doubleclicked on the file to open it(from the windows explorer). For this method to work, the Excel application must be clossed.

  • If the Excel application is open, then go to the VB editor and type application.EnableEvents=False in the immediate window (and press enter to run it). Just be aware that this will disable the events on every file in that instance of Excel. You will have to set it back to true or close the application (not just the file).

CaBieberach
  • 1,748
  • 2
  • 17
  • 26
1

Check if you don't have references to missing libraries, if so simply uncheck it. I had a similar problem and it helped in my case.

Michal
  • 11
  • 1