Why can I not change my project name? - excel

I am trying to change my Excel VBA project name but everytime I do this it always reverts back to the 'default' name of VBAProject.
So far I have tried renaming the project via the Properties Window and by Tools > VBA Project Properties - both times I saved the document but after closing and opening again, the name has defaulted back to VBAProject.
I have full access rights to this document and it is not ready only. I have Trust Access to VBA Project enabled.
What else could prevent me from doing this? I would have at least expected an error telling me I could not do this rather than lead me to believe this is possible!!

I was able to get the project name change to "stick" by clicking on Run - Design Mode before making the change. I clicked on Run - Design Mode a second time, saved the file. When I reopened, the name had still been changed. This is in Excel 2016 VBA Editor.

Related

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.

VBA References Not Saving

When attempting to open a database file through Access 2016, I'm immediately brought to VBA with a compile error: user-defined type not defined. I've rooted the problem to references not being selected (specifically, Microsoft Excel 16.0 Object Library and similar ones for Word, Office, etc.). I tried to go in, select the references to use them, save the file and try opening it again. However, I'm still brought back to the same error and the references I just selected all are unchecked again.
Does anyone know what could be causeing the references to reset and how to stop them from doing so? My co-workers running the same database file have them selected by default when they run it, but I just installed Access so that might be contributing to the issue. Any help or insight would be greatly appreciated!
Try opening the database without any of the onload options and making the necessary changes, then save, close, reopen. To open without additional criteria in Access just open the file while holding the shift key.
i.e. shift + double click the file

Excel VBA Unexpected Error 419 - Permission denied to use object

I have an Excel spreadsheet with VBA programming, form activex controls, form controls. The spreadsheet has worked normally, until last week. I think the problem started when the automatic installation of windows uptade took place, however it might be only coincidence, since I am not positive if this is the cause. Now, the spreadsheet opens and immediately a small window appears that indicates :
“Visual Basic for Applications - Permisson Denied to use object (OK,
Help)”. Selecting help, minimum information and it is irrelevant.
Selecting OK, another window pops out “Visual Basic for Applications -
Unexpected error 419 (OK, Help)”
I cannot even save the sheet to another name. The VBA code cannot run. If I open any new spreadsheet, Excel functions normally, also with its VBA. Just before having this problem, every time that I opened the spreadsheet a window appeared, indicating that Excel blocked the functionalities of the ActiveX controls and asking that if I would allow the use of ActiveX. Today, I enabled all macros and also all activex controls. My previous backups of this spreadsheet have also the same problem. None works. I went to VBA Edit-->References and compared the Libraries I had and the Libraries that are there on the spreadsheet. It seems that no library is missing. How to solve that?
The permissions have changed on your workstation and/or network. Specifically, the folders that hold the DLL files that contain the objects referenced in the VBA. As an example (and I don't know if this is exactly the case, but an illustration), if your code is referencing the Microsoft Scripting Runtime (many VBA projects do), your code needs permissions to access C:\Windows\SysWOW64\scrrun.dll. (I found this by calling up the VBA editor, selecting Tools-->References, then selecting Microsoft Scripting Runtime and reading the bottom of the dialog window for the location.)
This is the location of the DLL on my workstation. Yours might be different or it might have moved during a systems update or the permissions to access that folder may have changed. You'll have to check the locations of all the references in your VBA project to determine this. Sometimes the libraries referenced are located on network drives, which can complicate matters if the network permissions change.
I decided to try to export all the forms (*.frm; *.frx). Everything went fine until I came across to a specific form that had a shockwaveflash object. At this point the message "Permission denied to use object". Bingo!
I then tracked the location on my workstation of such shockwave object reference and applied full administrator control. However, I still could not use shockwave objects. I then uninstalled flash and downloaded the lates shockwaveflash plugin from Adobe. When I open Excel->Developer->Insert->ActiveX Controls->More Controls -> ShockwaveFlashObject and then insert the object in a sheet, the message: "MS Excel - Cannot insert object" appears. I have manually deleted the "*.exd” from C:\Users\[User ID]\AppData\Local\Temp\Excel8.0. Also deleted from C:\Users\[User ID]\AppData\Local\Temp\VBE\, but the problem was still there: "Microsoft Excel - Cannot insert object".
To solve the issue I finally accessed the VBA editor and deleted the userform that had the ShockwaveFlashObject in it. All went back to normal afterwards.

Debug Excel add-in written by JavaScript API on an existing workbook

I am trying to develop an Excel add-in by using JavaScript API for Excel.
I can already make some samples run, launch debugging under Visual Studio. Every time when i launch debugging, it opens a new workbook of Excel.
However, most of time, I need to debug an add-in on an existing workbook. For instance, here is an add-in sample, which opens a blank workbook and adds blank sheets to it. However, I want it to add blank sheets to an existing (opened) workbook. Does anyone know what I should set to debug it on an existing (opened) workbook? Should I modify some lines of code?
Edit 1:
From http://dev.office.com/docs/add-ins/get-started/create-and-debug-office-add-ins-in-visual-studio
To use an existing document to debug the add-in
In Solution Explorer, choose the add-in project folder.
Note Choose the add-in project and not the web application project.
On the Project menu, choose Add Existing Item.
In the Add Existing Item dialog box, locate and select the document
that you want to add.
Choose the Add button to add the document to your project.
In Solution Explorer, open the shortcut menu for the project, and
then choose Properties.
The property pages for the project appear.
In the Start Document list, choose the document that you added to the
project, and then choose the OK button to close the property pages.
Here is the resulting configuration that you should see:
After that just press F5 (start debugging), and you should be good to go.
~ Michael Zlatkovsky, developer on Office Extensibility team, MSFT
For anyone else running into this same issue (i.e. tying to set up an existing worksheet for debugging) without having to jump through 3 hoops to insert the add-in every time, this worked for me:
Set the Start Document to "New Excel/Word/etc Document"
Hit F5 to start debugging.
The resulting new document will be read-only and it will be in the Debug/Release folder.
Close the document, don't save it.
Copy the document to the folder where your Web Add-In manifest is and renamed it to whatever name you prefer.
Uncheck "Read Only" int the file's properties.
Set the Start Document as described by Michael in his response above.
If you start debug now, the add-in "should" load automatically. If you start without debugging (Ctrl + F5), you should be able to close the document and open it (or a copy of it) from anywhere in the PC and it should load automatically. You can even make changes to your JS code and reload the taskpanes/dialogs and it should take effect.
What did NOT work:
Using a blank start document and saving it after inserting the add-in. Once you save it, it loses its connection to the developer add-in.
If you start any document in debug mode and save it, it will NOT work the next time! If you want to make any changes to it, DO NOT start in debug mode.
I am not sure if any of these quirks are by design or if a Windows/Office update messed it up for me. Regardless, this is a very painful experience compared to developing VSTOs.

Issue With Excel Template Files

I have been using Microsoft Excel 2003 since it first came out and am only just coming across an apparent problem with it. I have a number of .xlt files that are used throughout the company and have never had any issues with them. However, it has just come to light that there is a user who can change the template.
Ordinarily you open the Template file (e.g. Template.xlt) and on opening it find it is called Template1. On pressing the save icon you are taken to the the Save As screen with the default option to save the file as Template1.xls in MyDocuments (Default location).
In this one case though, the user opens the file as Template, and on pressing the save icon overwrites the original .xlt file. I have never seen this before and am bamboozled. Any ideas please?
How exactly does the user open the template?
If a template is opened by double clicking the .xlt (or .xltx/.xltm) file in Windows Explorer, the template generates a new Excel file based on the template.
If an .xlt (or .xltx/.xltm) is right-clicked in Windows Explorer and then the "Open" command is selected in the context menu, then the template file itself will be opened.
If an .xlt (or .xltx/.xltm) template file is opened via Excel's File > Open dialog, the template file itself is opened.
A shortcut that leads to an Excel template behaves in this way:
double-click - creates a new file based on the template.
right-click > New - creates a new file based on the template.
right-click > Open - opens the template itself.
Edit: if the behaviour of double clicking a template file (or a link to a template) occurs only for one user, you may want to unregister and re-register Excel 2003.
Quoting from this question at the Microsoft Answers forum:
> Start>Run>excel /unregserver
> - note the space between excel and /unregserver then
> Start>Run>excel /regserver
> - again note the space between excel and /regserver
I know it's not the best form to answer your own questions, but hopefully someone else will be able to benefit from the solution that I have found.
In order to solve this, download and install a program named FileTypesMan.
Run the program and find the .xlt extension. In an ordinary working system this will have at least New and Open as options with New set to default. In this case there was only Open as an option. Create an option for New and set this to default.....Presto, sorted.

Resources