Environ("username") - compile error Excel 2010

MerkDog

New Member
Joined
Jan 9, 2007
Messages
23
Hi,

The following code used to work fine for me in Excel 2003:

Code:
MsgBox Environ("username")

In 2010, I get a compile error: "cannot find project or library". I get the same error on trying to use the Chr function, which makes me think it must be something obvious...but I can't figure it out.

Thanks
MerkDog

Excel 2010, Windows XP
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
Code:
UserForm1.Show VBA.[__MIDL___MIDL_itf_m_0001_0016_0001].vbModal
Well, of course -- who wouldn't know that?
 
Upvote 0
Rory,

(a) How did you suss out the .[__MIDL___MIDL_itf_m_0001_0016_0001]. bit? "__MIDL___MIDL_itf_m_0001_0016_0001" returns zero hits on Google, so you didn't find it on the internet.

and (b) :( alas, this is not backwards compatible with Excel 2007.
 
Upvote 0
Oh, I know it's not backwards compatible - you'd have to wrap it in an #If VBA7 block.

Does no-one read the Object Browser anymore? Deary me... :)
 
Upvote 0
Rory,

(a) How did you suss out the .[__MIDL___MIDL_itf_m_0001_0016_0001]. bit? "__MIDL___MIDL_itf_m_0001_0016_0001" returns zero hits on Google, so you didn't find it on the internet.

and (b) :( alas, this is not backwards compatible with Excel 2007.

Isn't that a hidden Property ?
 
Upvote 0
Select vbModal in the OB and you will see it's a member of VBA.__MIDL___MIDL_itf_m_0001_0016_0001
 
Upvote 0
Select vbModal in the OB and you will see it's a member of VBA.__MIDL___MIDL_itf_m_0001_0016_0001


DOH!
:p :p :p :p

I had also looked there in 2007 OB, but failed to do it again in 2010 OB. Sheesh! And yes, I oughtter have mentioned the whole #IF VBA7 as a workaround, shame on me.
 
Upvote 0

Forum statistics

Threads
1,215,559
Messages
6,125,517
Members
449,236
Latest member
Afua

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