Missing reference and "Error in loading DLL" - excel

I have an Excel tool I've been building at work to automatically generate PowerPoint charts from data on Excel sheets. I've been moving the project back and forth between my work and home computers.
At work I have Excel 2013 and at home I have Excel 2016. So when I move the file from home to work, I have to go into references and uncheck the "MISSING: Microsoft PowerPoint 16.0 Object Library" and check "Microsoft PowerPoint 15.0 Object Library"...no big deal.
Until this morning. When I open the VB Editor I get a messagebox
Error in loading DLL
I can't open any of the forms of modules...I just get that messagebox.
When I go to references I've tried
Uncheck the missing entry for v16 and check the entry for version 15
-- I get the error in loading DLL message
Just unchecking the entry for v16 -- I get the error in loading DLL
message
Leaving them both checked -- I (obviously) get the error message
"Name conflicts with existing module, project, or object library"
Uncheck the missing entry, check the correct entry, and move its
priority above the (unchecked) missing entry -- I get the error in
loading DLL message.

Had this issue before. My macro used the Microsoft Outlook 12.0 Object Library and was designed to work with that for all users of the team. However since an update to Office 365 was planned one of the IT guys had opened the macro with the new Office 365(and Microsoft Outlook 16.0 Object Library was set to be used). After this all of the users had:Error in loading DLL on their screen as they were still on the old Office 2007 and the new library Microsoft Outlook 16.0 Object Library was in the References list. Tried in vain to unselect the new one and select the old library.
My solution to this issue:
open a new excel file(not a macro)
go into the Ribbon(office 2007 & 2010)->Excel Option->Trus Center tab->Trust Center Setting button->Macro Settings
select option: Disable all macros with notification and then click Ok button
Close the Excel file opened(not the excel window) - from the lowest X on the right corner
Open the macro using the Ribbon and then option Open
Get into the dev mode(ALT+F11) and go to Tools->References then unselect the broken Excel library(the one with MISSING:)
Select the correct library from the list and click OK
Save the macro and then close it.
Revert the selection done at step3 to option:Enable all macros and Voila!

Related

Reference to Outlook becomes missing, leading to Excel error: Unable to Load DLL In Excel 2010

I have a macro to import data from Access to Excel. One component of the import is to prompt the user to see if they would like to email the workbook. If yes, then a new email opens with the workbook attached. To accomplish this, I referenced the Outlook 14.0 object library.
After a few refreshes of the data from Access, I began to get run time errors which I have since fixed. However, now I get a notice that Excel is "Unable to Load DLL" when I try to open a module to modify it.
When I look at the libraries referenced, the Outlook library indicates that it is missing. I am unable to deselect the library in Excel 2010 and have to open the workbook on another computer that is running Excel 2016, where everything works. Once I deselect the library and save it, I can use the macro again in 2010 and modify the code.

Excel 2013 Crashes when Adding Userform in Visual Basic window

I have a user who just got a new computer (Windows 10 Pro running Office 2013) and he can no longer open a macro enabled workbook.
I finally identified that the Userforms are causing the issue when I created a new workbook and added some VBA to it. Everything worked fine until I went to insert a Userform, that's when it crashed. I did some additional testing and found he can open .xlsm files except when a userform is in the VBA.
I looked into the References in the VBA window and checked the libraries, he seemed to have what he needed and I added anything I thought was missing but nothing helped.
Visual Basic for Applications
Microsoft Excel 15.0 Object Library
OLE Automation
Microsoft Office 15.0 Object Library
Microsoft Forms 2.0 Object Library (keeps unchecking itself but even when checked doesn't help)
Ref Edit Control
What references could I be overlooking here?
The VBA code is not affecting it, I ran the opening code without any forms and it opened and enabled macros just fine.
What is preventing Excel from running a macro enabled workbook with userforms or adding a userform?

What is the easiest way to add Macro automatically to a set of Excel Files

I have a macro function that I have added to an excel file. My question is how can I add the same macro function to a specific set of excel files without copy pasting the macro in each excel vba editor.What is the easiest way to achieve this?
The objective is for the users who have no knowledge on excel macros should be able to easily add Macros to excel and execute it.
If the people who are importing the macros are also the users of these macros you might want to create an add-in out of your vba macro. The procedure is described here. The users would just have to install the add-in on their PCs once(step 4). They can then use the add-in for several Excel-files.
This needs to be done by each user once:
Step 4: Install the Add-In:
Go to Tools > Add-Ins to open the Add-Ins dialog. If you have stored your Add-In in the default location you will see its name displayed in the Add-Ins available: window (if you have stored your Add-In in a different folder, use the [Browse] button to find it). Click on your Add-In's name to see its description at the bottom of the dialog box.
To install your Add-In place a tick in the check-box next to your Add-In's name and click [OK]. [Click the thumbnail below to see a full-sized image]...
Installing your Add-In (Excel 2002) Installing your Add-In (Excel 2000/97)
As soon as the Add-In is installed its functions will be available in Excel. Find them in the User Defined section of the Function Wizard (Paste Function Tool) or simply type them into a cell as you would any built-in function. The Add-In will remain installed until you return to the Add-Ins dialog and uninstall it by removing the tick from the check-box.

Excel Addin (File.xll) will not open properly in excel 2007, but works fine in 2003

How do i make excel 2007 treat the xll addin the same when opening programatically, as it does when browsing via the addin-manager?
i have an excel addin (XLL file) that works fine on an old XP box, running excel 2003 (Excel XP)...but not on windows 7 running excel 2007.
On my new Windows 2007 machine, running Office/Excel 2007, the same XLL has odd behavior.
In Excel 2007, When i goto the excel addin manager, browse to the xll, and then load it...the XLL works just fine...but just for that session.
But, after i close this instance of excel, and then re-open excel (so, now the adddin will be loaded programatically from the Excel\Options list from the registry - which is how excel normally loads addins)....Excel throws an error saying
"The file you are trying to open, 'Addin.xll' is in a different format than specified by the file extension. Verify that the file is not corrupted and is from a trusted source before opening the file. Do you want to open the file now?"
If i click 'yes', then the xll opens with garbage text, and does not work.
However, if i kill excel, open the registry, goto HKEY_Current_User\Software\Microsoft\Office]12.0\Excel\Options\
and remove the [OPEN] item which points excel to open the addin programatically...then excel opens fine (without the addin loading...obvs).
Again, if i then goto the Excel Options --> addin manager
and re-add the Addin...then it will load and work just fine.
But again, after i close excel and re-open., i'll get the same error from above.
I've read that Excel sets the 'Current Working Directory' when you open the addin from the "addin manager --> browse" method...but not when excel opens the addin programaticaly.
So...what can i do to make excel open my addin correctly? It works fine with Excel 2003...and it works fine the 1st time in Excel 2007...so its got to be a problem with Excel.
i figured the answer to my own question...so i thought i'd share.
On the new windows 7 box, there must be an environment variable 'PATH' to the folder directory where the addin and its associated libraries live.
My addin files are located in C:\AddinFolder\
So here are the steps to fix
1) right click on MyComputer and select "properties"
2) select the "System protection" item from top left list
3) click on the advanced tab
4) click in the button "Environment Variables"
5) in the lower section (system variables) scroll down till you find the "Path" variable and then select "Edit"
6) Add to the end of the string the path to your addin library. The list is a set of directory paths, separated by semicolons. So, i added ";C:\MyAddin\" to the end of the string, which already had a bunch of paths listed for a variety of other programs
7) click Ok a couple times to get out of that set of dialogue boxes
8) open Excel with the addin set to load, and voilla...it works perfectly
**note...don't delete the contents of the Path variable..just add to it...else some other software might stop functioning properly

VBA created with Excel 2003 loaded OK in Excel 2007, but there's nothing in Project tree of VB editor

I have created a VBA in excel 2003 and save it in xla format. This AddIn add a new menu and some submenu in toolbar of Excel. All work well until I upgrade to Office 2007, then I open the xla file. No error message shown, but when I view the macro List, no items there. I open the Visual Basic editor. My old Project (named ML) is still there, but nothing in the Project tree, just default files as when add a new blank project.
I open the xla file with notepad, and my variable, function name are still there. Anyone has experience in this weird behavior, please give me a clue.
Thanks in advance.
Toolbar add-ins generally appear in the add-ins tab of the ribbon in Excel 2007. Make sure you have the add-ins tab displayed (if not you can turn it on under excel options).
If that still isn't working you'll need to go online and read up on altering the code to conform to the ribbon - there are a lot of resources out there should you need to do this.

Resources