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.
I need to open an Excel file for editing included in a Visual Basic project
I'm able to open it using Excel application. The file is opened in an external Excel instance.
Is there an extension that allows to open Excel files inside Visual Studio as other documents?
Update: I'm searching something similar to Excel Viewer but I need an extension for Visual Studio (not Code) and I need an editor to modify the content of Excel files. I think that the extension has to do something similar to How to Integrate Excel in a Windows Form Application using the WebBrowser.
Maybe you could try to modify the Excel file as a csv file instead, depending on how complex you file is (if it contains formulas it will not work). I have tried using csv before and I did not notice much difference between csv and excel files when I was using it and csv could easily get data, but if you need formulas, you may have to compute them in your code before editing the file.
I believe you can just right click on the file and select Open With > Visual Studio. Or within Visual Studio go to the Menu Bar and select File > Open and seect the file. Hope this helps!
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
.
Can anyone explain me how to display a word and excel in browser.
I had set content type as application/vnd.ms-excel for excel but still not working.
PDF is working fine.
You can save your word and excel files as webpage, just select that option webpage in the save as menu.
A browser is only able to display files from Microsoft Office when the application is installed. For some versions of Microsoft Office viewer applications exist.
But displaying Word and Excel files in modern browsers (especially Internet Explorer) has the drawback that the browser does not display the file in the original window but rather opens a new window.
This in turn is good because current MS Office versions hide some functions and windows when a file is not opened in the application but in the browser. This sometimes makes it impossible to uses formulas in Excel or reopen a file that was opened in readonly mode.
In short: if you want a good experience for your users either accept (if they have it installed) that a second window is opened for the Word and Excel file you present or (if possible) convert it into a html equivalent (which will have a different look) or a pdf (which then automatically is readonly and kind of protected)
I have a c# application that uses Microsoft.Office.Interop.Excel. The application runs for a long period of time! If I try to open Excel manually on a different worksheet from the one the c# application is processing the c# application fails with some HResult cryptic message.
Is there a limitation with Microsoft.Office.Interop.Excel in that only 1 excel process can run at once?
Any information around this issue would be great!
thanks for any help!
Mostly, it is how your code is interacting with Excel that is the problem. Many people use ActiveCell, ActiveWorkbook, and so on. Therefore, when you open another workbook during this process, you will generate some kind of error. To avoid this, open another instance of Excel. In our shop, we created a shortcut in our "Send To..." folder. We could then just right-click on the file in Windows Explorer, select "Send To..." menu, then click on our shortcut. This saved us from having to open Excel, select file open, browse to file, and so on.