VBA error in 64-bit Windows 7

anziga

Board Regular
Joined
Feb 4, 2011
Messages
55
I have the following code(in Workbook_open) which works OK in 32-bit Win7 system but in 64-bit system it returns an error message, compile error in hidden module.
Code:
Dim username As String
username = Environ("USERNAME")
If username <> "jack" Then
If username <> "jill" Then ActiveWorkbook.Close True
End If
Is there something I need to do differently for 64-bit Win7 system?
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
Hi Sandeep

Did you try with your logon/user name in the code, i.e. did that particular Excel document remain open?
 
Upvote 0
Check for and remove, any erroneous reference(s) in the Visual Basic Editor (VBE) i.e. references that start with MISSING:
 
Upvote 0
I did check, couldn't find any... but checked from my 32-bit system, not that problematic 64-bit though, not sure does that make any difference anyway?
Check for and remove, any erroneous reference(s) in the Visual Basic Editor (VBE) i.e. references that start with MISSING:
 
Upvote 0
I did check, couldn't find any... but checked from my 32-bit system, not that problematic 64-bit though, not sure does that make any difference anyway?

Yes, it makes a huge difference. Of course there's no missing references on the 32-bit machine or else you'd be getting the same error message on that machine as well.
 
Upvote 0
I meant that I'm not getting any error.

If you want to code such that the workbook will close if the username is not jack or jill, then use

Code:
Sub test()
    Dim username As String
    username = Environ("USERNAME")
    If Not (username = "jack" Or username = "jill") Then
        ActiveWorkbook.Close True
    End If
End Sub
 
Upvote 0
Ok, I need to modify my code accordingly and test again. If the error message still appears, need to ask the client to have a look at those erroneous/missing references.
 
Upvote 0
Latest update... the problem was that client's system, now it's rectified and in order. Thanks guys for your help and tips.
 
Upvote 0

Forum statistics

Threads
1,224,587
Messages
6,179,740
Members
452,940
Latest member
Lawrenceiow

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top