EXCEL - Error while opening excel workbook - excel

I have Office 2007.
Each time I launch Excel, or open an existing file, it tries to access some old file and I get the following error pop up:
'E:\xyz.txt' could not be found. Check the spelling of the file name, and verify that the file location is correct.
If you are trying to open the file from your list of most recently used files, make sure that the file has not been renamed, moved, or deleted.
Please help on this.
Thanks in advance!

Maybe you have an old add-in still active?
Developer > Add-Ins
if you see any custom add-ins, deactivate them and see if the problem remains.
Alternatively you could check in the VBA window what xla / xlam files are active and see if the file you mention is hiding somewhere in the code thereof

Related

Corrupt VBA Project Module Not Found Error

I have a workbook that was saved yesterday afternoon, and was working perfectly. I have opened it this morning, and none of the modules in the VBE are 'found'. Visually I can see them all sitting there.
When trying to open any of these modules to edit the code, the windows are greyed out, as below.
When I try exporting the code modules, I get the 'Module Not Found' errror.
Does anyone know a) why this has happened, and b) how can I fix this?
I thought initially it was the instance of my Excel, so have restarted the PC.
Any help is appreciated!
I managed to find a workaround to this problem, so sharing the solution in the event that someone else comes across a similar problem.
It seems that the VBA Project got corrupt somehow. Below, find some suggestions and workarounds in trying to solve something similar in the future.
This is what worked for me. Convert the .xlsm file to a .xls file. You can do this by changing the file extension when renaming the file.
You can also try to convert to .zip file type, and then convert back to .xlsm. Note: convert COPIES of your original, just in case.
Other suggestions (as Chris Nelisen suggested) are:
Export your VBA modules regularly
Save different versions as you are building
My workaround, works perfectly:
Open Excel in safe mode (pressing and holding Ctrl while you start
the program, or by using the /safe switch (excel.exe /safe) when you
start the program from the command line)
Open corrupted workbook (from safe mode, File->Open-> navigate)
Do not enable macro if asked
Make sure macro is present (Alt+F11) - not necessary
Save as new workbook
Close safe mode excel
Open saved workbook as usual
This is a well-described issue, and it exactly matches what I have just experienced (even including the fact that I haven't been versioning recently).
My file has an xlsb suffix. Resaving with a different suffix did not work for me on the same PC, but I emailed the file to another PC, opened it, saved as xlsm, sent it back to the original machine and it now works fine again. I can even re-save with my preferred xlsb suffix and it still works.
I've also run this script to make a backup of my modules:
Sub ExportVbaModules()
'Acknowledgements to Andy Pope [ozgrid thread 60787]
Dim objMyProj As VBProject 'if error, go to VBA editor - tools - References - Microsoft Visual Basic-Extensibility5.3
Dim objVBComp As VBComponent
Set objMyProj = Application.ActiveWorkbook.VBProject
For Each objVBComp In objMyProj.VBComponents
If objVBComp.Type = vbext_ct_StdModule And objVBComp.Name <> "" Then
objVBComp.Export "C:\Users\MyName\VbaBackups\" & objVBComp.Name & ".txt"
End If
Next
End Sub
The And objVBComp.Name <> "" stops it from erroring when it encounters a corrupted module but turned out not to be necessary as the 'fixed' file contained no corrupted modules.
Since that export routine is so fast (40 modules / 100kb saved in <1s) I will be assigning it to a button on the ribbon with a better naming convention for the files it creates.
I copied my .xslm file from my PC to my OneDrive account.
I open the file on my iPad OneDrive account and then export to Excel for iOS. The file opens and says links and macros are disabled. I then save a copy of the file back to the OneDrive account. I go back to my PC and open the file from OneDrive. I re-establish the links.
The macros are from a backup. This is an issue if you aren't backing up your macros.
Do you have this file on OneDrive?
If yes, I was facing that issue, and resolved restoring the last save. If you open OneDrive site (onedrive.live.com), find the file, and select Version History. Download the penultimate.
When this happens on 64 bit Excel, I simply open the exact same file in 32 bit Excel and the macros re-appear.
When this happens on 32 bit Excel, I simply open the exact file in 64 bit Excel and the macros re-appear.
Try to open the excel file in repair mode and save as the file one more time.
Open and Repair
I tried everything suggested and nothing worked. I could only see the module when I opened my VB editor. It was not available through the view macros ribbon shortcut. I was unable to export the module or copy it to a new workbook.
What finally worked for me was emailing it to myself, downloading it through my 365 outlook account via a web browser, and then the code was there.

Why does the VBA Excel Addin code disappears and doesn't function after I close Excel and open a new Excel file?

I created a simple vba addin that colors cells based on their value, and I created a function that calls it with a shortcut then I saved it as an Excel addin and added it to Excel.
The problem is the addin works fine when I add it the first time, but when I open a new Excel file, I need to disable and enable the addin for it to work.
Update: I tried it on another computer and it works, but it shows an error that when I ignore it works fine. I am adding screenshots for the error and code
Error Message
Code
Sometimes, Excel will open workbooks in another Excel Application. This second application can sometimes face some issues with addins. You should double-check that the new file is opened in the same Excel Application. By looking at the task manager:
In this example, I'm using Window 10 and you can see that Book3.xlsx is in a different Excel Application than Book2.xlsx and Book1.xlsx
EDIT:
This question could also be of interest to you. The accepted answer reads:
This problem results from security patch in KB31152, released in July 2016. According to private communication with Microsoft software engineers:
"With this update, we changed the behavior of Excel so that it will
not load certain file types (including .xlam) when they are untrusted.
The easiest workaround is to find the add-in that is causing you
trouble, right-clicking on it in Windows Explorer, and checking
Unblock"
An easier approach is to simply place the add-in in a Trusted Location
(in Excel, go to File > Options > Trust Center > Trust Center Settings
Trusted Locations), such as the following folder, and load it from there:
C:\Users\%USER NAME%\AppData\Roaming\Microsoft\Excel\XLSTART
EDIT2:
And don't forget the option of just restarting your computer just to make sure that the problem is still there.

PERSONAL.XLAM is being opened as read-only

I've been using a PERSONAL.XLAM file for years in Excel 2013(?) with no issue. I am now using Excel for Office 365 and am having a problem using the same file.
I used to be able to open a workbook, PERSONAL.XLAM would open along with it, and I could go into Developer > Visual Basic, and change VBA code and save. Perfect.
Now, with Office 365, I get an error saying I can't save because PERSONAL.XLAM is read-only. I checked the Windows file attributes, and the Read-only checkbox is not checked, so I'm not sure why it would be opening as read-only.
In addition to now using Office 365, I'm also on an entirely new PC, so there might be something I'm missing, but I don't know what to do.
Edit: I think I found a new wrinkle. I moved the Personal file from my XLSTART folder to my desktop. If I open the Personal file directly from there, I get an error that says, "Sorry, Excel can't open two workbooks with the same name at the same time." Does that mean it is open somewhere else already?
I figured it out. I actually had code in Workbook_Open that looked at the Application.UserName. If it wasn't a match for what it checked against, it made the Personal file read-only. And as I mentioned before, I got a new computer and my name was set to something different. After I changed my username back to what I used to use, everything is back to the way it was.
If it wasn't for that "security check," I wouldn't have had any issues. In other words, you can have the XLAM file in the XLSTART folder and make changes to it while you have it open, which is what I wanted.
This is obviously a self-imposed, yet accidental, issue. I'll mark it as answered, but if it would be better to close it, that's fine too.

proj.xll add-in wont load after added to excel

I have searched and searched to find a solution to a .xll excel add-in not working correctly.
The add-in is proj.xll (https://github.com/jbuonagurio/proj.xll)
The instructions simply say to;
Copy proj.xll to %USERPROFILE%\AppData\Roaming\Microsoft\AddIns.
Go to Excel Options, Add-ins, Manage Excel Add-ins. Click Browse, and select proj.xll.
After doing that I load my spreadsheet and get this error;
The file format and extension of 'proj.xll' don't match. The file could be corrupted or unsafe. Unless you trust its soruce, don't open it. Do you want to open it anyway?
I click yes and I get cells with "LËÝbÉÜRichcÉÜPEL" etc gibberish text in them.
Some websites indicate that a .dll file is missing which is needed by the add-in, but I am unsure what dll file that is, how to find out what dll file I need and where to put the dll file if I do find it.
I have tried to get this add-in to work on multiple computers and different versions of excel installed.
If anyone could offer assistance that would be fantastic.
Thanks,
You can use dependency walker (here) to inspect the generated xll and to look for missing dependencies. Also be sure that the xll is in the same architecture (64 vs 32 bits) than excel.
See also : "addin.XLL is in a different format" issue, cannot open the xll I created by myself
.

vba excel: Add-in in XLSTART ignored

We have a vba excel Add-In installed in the users XLSTART folder. This works fine.
Now we did a small code change in a function and tested it on the developer machine. This works fine as well.
After deploying the Add-In, it's completely ignored by Excel. It's not loaded on start-up, no error message, nothing. If we copy again the old versin to the XLSTART folder, it works as expected. We did the same code change to a Word macro which is installed in the STARTUP folder. This one works fine.
Any ideas why the changed Excel Add-In gets ignored?
Possible reasons are:
It does not get opened
Permissions or macro security prevent it from functioning
THe original XLA is actually being loaded from somewhere else
I suggest you do some tests:
- When you look at Tools->Addins is the addin checked? If so it has been installed somewhere probably other than XLSTART
- when you place the revised addin in XLStart does it get opened and is it visible in the VBE?
- If you remove it from XLSTART and then open the XLA file as if it was a normal workbook does it work?
Just had this problem with a user. The reason was that the xla (ours is password protected) was not read-only. I know it is ridiculous but the xla was ignored until this changed.
Hopefully this will help others avoid such headaches.

Resources