I am learning EXCEL vba and was trying to create a macro that ran when EXCEL was opened. It was saved as "Personal Workbook" and now every EXCEL spreadsheet I open has this macro. Should have selected as "This Workbook". How do I get rid of that macro so that Workbooks open without it.
Thanks
The personal workbook will be in Appdata/Microsoft/Excel/XLSTART. Just remove it from there. To get to your app data folder press windows+r and type %appdata%
If you just want to remove the module in Personal workbook that was created, rather than the whole file:
In the Visual Basic Editor (Alt + F11 to open)
Find the PERSONAL.XLSB VBA Project in the Project Explorer (Ctrl + R to open in the VBE)
Press the little + sign next to VBAProject.
Press the little + sign next to the Modules folder in the project.
Find the module containing the code, right-click the module and select Remove ModuleName
Using the gui to get to the file.
In Excel
File -> Options
Click on "Customize Ribbon"
In the right hand pain there is a "Developer" checkbox that is unchecked by default, check it.
Now go to the "Developer" ribbon and click "Macros"
Click the macro you do not want an click "Delete".
Related
I have a macro that I have coded in a VBA module, saved in a .dot file. However, when I go to Customize Ribbon in Word and try to add it, it does not show up. I have tried saving it in the Word STARTUP folder as well as the Custom Office Templates folder.
I would like to have the macro set up so that it loads in all Word Documents as a clickable button on the Word toolbar/ribbon.
I can tell you for dotm files. I think it should work the same for dot. However, you might as well switch to dotm since you have Word 2013.
Exit Word.
Put the dotm in %appdata%\Microsoft\Word\Startup. You mentioned you have already done this, which is good!
Restart Word.
Check File | Options | Add-Ins and make sure your dotm is listed under "Active Application Add-ins".
If not, hit "Go" at the bottom to manage "COM Add-ins," and hit the checkmark by your dotm's name.
Right-click the ribbon and select "Customize Ribbon."
In the "Customize Ribbon" dialog, under "Choose commands from," select the "Macros" category.
All your macros should be listed there, by project name. You may have to hunt through the list as they will all start with Project. by default. You can change your project's name in the VBA editor, Properties pane, to make it easier to find.
Choose the destination and hit Add>>.
Tested in Word 2013, Windows 8, with numerous dotm files.
I am writing a VBA macro to fill a web form with values from spreadsheet.
I have completed macro to fill all form fields except one to click on a button in form to Browse for files.
Below is the macro line to click the browse button.
IE.Document.getElementById("notification_picture").Click
I'm clueless on how to do the next steps i.e. to browse to a particular folder, select and open the file.
Any help is appreciated.
Man... particularly deal with IE is a pain...
You could use
Sendkeys "%S"
It will save it in Downloads folder and then you can move it, open or do whatever you want.
Many will say it is not good to use it because if the user change the focus while the macro is running it will not working, but it is the simplest way.
I initially created two new modules in a fresh workbook. I accidentally used the "Export File..." feature in the Visual Basic project explorer. This created two new .bas files.
The problem is that now that I have these two objects, they are opening up every time I attempt to launch excel. The files appear to be save in this directory: C:\Users\f370830\AppData\Roaming\Microsoft\excel\XLSTART. Excel points to this directory when I try to save either the VBA object or the excel book that they launch in.
I do not see the files in this directory. I even deleted the directory using both windows explorer and the command line. However these files still show up my VBA project explorer and launch in new windows when I start excel.
Any suggestions for how to delete these files and prevent them from launching every time I start excel?
I was able to solve the issue. Like I mentioned in my comment above, I was able to track down the directory storing the two rogue .bas files using the SysInternals program Process Explorer. The files were being saved here:
C:\appsensevirtual\S-1-5-21-1781428526-1902518210-316617838-164488\{B0970185-A624-496C-BE3B-08CE8AAA200A}\_Microsoft Office 2016\Device\HarddiskVolume1\Users\f370830\AppData\Roaming\Microsoft\Excel\XLSTART
as opposed to the normal 'users' directory. Just deleting the .bas files did not stop the two workbooks from launching when I open excel. For some reason opening excel would recreate the .bas files in the XLSTART folder.
I just deleted the entire XLSTART folder, which solved the problem. A new XLSTART folder was created on my next excel launch.
One small side effect is that excel now opens into a grey screen as opposed to a fresh worksheet. But that isn't a big deal to me, 9 times out of 10 I am opening existing workbooks.
On windows, open the workbook in question. Once opened, press ALT+F11 to open up the VBA editor. From there, right click on the module you want to delete in the left-hand navigation pane, and select DELETE (may be called REMOVE). Excel will likely prompt you to export the module again before removing it; I would suggest saving a copy somewhere but this is entirely up to you.
This worked for me:
*************** How to remove the personal.xlsb vba project *******************
Step 1:
On Windows Explorer
*Click on view tab at the top, three options to the right of file
* Click on options
* On the drop down menu click on change folder and Search options
* Go to view then click show hidden files, folders, and drives
* Click apply
* Note, the Personal.xlsb is a hidden file thats why the above is done first
Step 2:
On windows explorer
* Go to Windows-SSD(C:) i.e the C: folder
* Double click Users
* Double click the user in question, Username
* Double click AppData
* Double click Roaming
* Double click Microsoft
* Double click Excel
* Double click XLSTART
* you should find the "Personal.xlsb" Microsoft Excel binary worksheet
* Select and delete
Reference:
https://www.youtube.com/watch?v=EXN-nKwfZ5o
"Any suggestions for how to delete these files that still show up my VBA project explorer and launch in new windows when I start excel and prevent them from launching every time I start excel?"
You apparently cannot delete an active VBA project if it is running. Close down Excel. Right-click and Open the file containing the VBA Project while holding the Shift key (this disabled Macros from running). In the worksheet you will see a message "SECURITY WARNING Macros have been disabled", DO NOT enable Macros.
Go to Developer tab | Visual Basic, right-click Module1, and Remove module should not be greyed-out. Save and exit. If all the modules are removed from the Project, the Project is removed as well. The principle may be that if the module or code or ActiveX control is being used, it won't let you delete.
I have Workbook named Test. And in The Test I have code that runs when the workbook is opened it shows me UserForm1 which asks me to login with username and password and it will hide applications so only the UserForm1 is seen. The problem is that you can open Excel again and open a new workbook, and there you can go to the VBA and see workbook Test's code and close or modify it.
If the login would be requested in the input box, you can not do the trick and circumvent the login part. Input Box allows you only click in the workbooks Input Box you can't press ALT + F11 and go to VBA code or if you try to open new Workbook and in there goto VBA code there wouldn't be the Test's code. How to do this, with the UserForm?
Thank you so much for all your help in advance!
If it helps I can copy the code to do this , but it's a little mess.
What you want to do is protect your project, then auto execute your macro.
To protect you project do the following:
In your Project Viewer, right click your project then under the protection tab insert your password. You will then need to insert the password when you want to access your script for each instance you have the document open.
I have a custom button (not an add-in, just a "shortcut" button) in Excel's quick access toolbar to run a macro in the active workbook. The workbook is modified and saved daily with a new filename. When the link is first created in the active workbook (call it Version 1) the macro runs fine. However the following day (filename now Version 2) clicking on the macro button opens workbook Version 1 and runs the macro saved in Version 1.
Is there a simple way to break the link and run the macro in the most recent active workbook?
The code is basic - it just opens up a userform and is saved in "ThisWorkbook"
Sub OPEN_DATA_USERFORM()
ufDATA.Show
End Sub
I will try to guide you through this, I hope it helps.
What we need to do is we need to call OPEN_DATA_USERFORM() from our "PERSONAL.XLSB" file. In VB editor screen, in the project explorer you will find a file called "PERSONAL.XLSB", you need to add an "Module" to that and add following code:
Sub KickOff()
Call Application.Run(Excel.ActiveWorkbook.Name & "!OPEN_DATA_USERFORM")
End Sub
By this we will be able to call the userform.show function from our PERSONAL.XLSB which is always running in the background when you open the excel.
PS: I am assuming your OPEN_DATA_USERFORM() is coded in your daily workbook.
UPDATE: PERSONAL.XLSB
Your file should be visible in your project explorer like below:
If it is not there record a dummy macro and select your personal file like below then it should appear in your project explorer in VBA screen: