Compile error thisworkbook

AlexPi

Board Regular
Joined
Apr 4, 2011
Messages
104
I searched but could not find anything that helped...

I have a spreadsheet that is updated by more than one user so I put in the code below that will show who saved it last and when. The problem I am having is that this works fine on my computer but anyone else who clicks save gets a compile error thisworkbook...

Any ideas?

Code:
Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
 
 
 
Sheets("Overview").Range("K2").Value = Environ("username")
 
Sheets("Overview").Range("K1").Value = Date
 
 
End Sub

I'm also having trouble with another part of code that works on my computer but no one else can use it. I have a check box that locks a range of cells. Other users also get a compile error for this as well.
Thanks!
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
It happens here...

Code:
Sheets("Overview").Range("K2").Value = Environ("username")

I'm not sure what the compile error is...I'll see if I can get on another computer to check.
 
Upvote 0
Select your workbook in the Visual Basic Editor and chhose Tools|References. Are any marked as MISSING? That's on a computer that gets the compile error of course.
 
Upvote 0
I don't see anything missing from tool/references...

The compile error says "Can't find project or library". It says that for both sets of code that don't seem to run on any computer but my own. Any ideas?

Thanks for your help.
 
Upvote 0
I expect that there is a missing reference on the computers that get the compile error. This should work:

Code:
Sheets("Overview").Range("K2").Value = VBA.Environ("username")

but the VBA qualifier shouldn't be necessary.
 
Upvote 0
You are correct! I checked again and there was something marked missing that I unchecked which fixed the problem...

Guess i missed it the first time around.

Thanks for your help!
 
Upvote 0
Just thinking about how I use this workbook...

Is there a way to prevent this on future copies of the workbook? This workbook is a template that is saved as different names depending on the project. Right now it seems as though I need to go to everyone who uses this template and uncheck this missing object for each copy they save.

Is there a way to adjust something in the template or adjust something in the persons computer once to fix this so I won't need to fix this every time the template is saved as another name?

Thanks!
 
Upvote 0
The missing reference was Extreme Suite Controls Active X Control 11.1.3.

This isn't on my template but when I open the template on another machine then click on tool/references I see this show up checked and MISSING in front of it.

Any ideas?

Thanks
 
Upvote 0

Forum statistics

Threads
1,224,616
Messages
6,179,909
Members
452,949
Latest member
beartooth91

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