This might sound like a simple question but I'm creating a macro in VBA that uses regular expressions. It turns out VBA doesn't inherently support regex and I need to add a reference to 'Microsoft VBScript Regular Expressions 5.5' to gain access to regex functions in Excel.
All my searching online tells me you need to go to Tools -> References menu to add/remove references that can be used in VBA.
The Tools -> References menu in Excel as obtained from Google
For the life of me I can't see where the Tools -> References menu is in my Excel. I've enabled the Developers tab and it's not there.
This is what I see
If it helps, I'm using Excel on Office 365 (which Wikipedia tells me is Office 2016) on a Mac. Please help me find how I can access the References menu in Excel (whether or not it can be accessed via Tools -> Menu or some other way). Thanks.
You need to open the Visual Basic editor. On the ribbon in Excel, select Developer, then Visual Basic. This will open the VBA interface in a separate window. On this new window, you should see the Tools -> References option.
You need to open the Visual Basic (for applications) Editor, or VBE. On the Developers tab, look for "Visual Basic". It should be the left-most item.
Or, you can press Alt-F11.
The VBE is where you'll find the Tools menu, and the References submenu.
Related
I cannot find the tools references button in my Exel VBA Editor (Office 2016 for Mac). It is supposed to be in the corner down left as marked below.
Also described here.
I googled for almost two hours now. Any suggestions?
Note: It's different to Office for Windows!
It's in the tools menu - top of the monitor when you have the VB editor open.
how can I modify Visual Studio 2015 to be able to search the internet (my fav search engine happens to be google) from the context menu in the code editor?
Ideally, I would like it to open as a new tab in my (default) external browser, because the internal web browser is still...lacking, shall we say?
I found one extension "web search" for older VS, but I have found no extension that works with VS 2015. I found no article that still works.
For comparison, when you're in Chrome, you can select some text, right click and say Search Google for 'what you selected'.
I think this would be handy when learning new technologies from a project that uses those technologies, or just for help.
Ok this turned out to be fairly easy. I just added a tool to Tools, External Tools
Command: C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
Arguments: https://www.google.com/?gws_rd=ssl#newwindow=1&safe=active&q=%22$(CurText)%22
I enclosed the $(CurText) variable around quotes (%22) so that it would search on the exact phrase.
Then, to make it more accessible and actually put it in the context menu (and other places), I clicked the Move Up button to make it the first command, then customized the Standard toolbar to include Tools.External Command 1. I also added it to Other Context Menus | Html Context and Editor Context Menus | Code Window
Then I also went into Tools, Options, Keyboard and associated Tools.ExternalCommand1 with Alt+G
IMPORTANT: Because Visual Studio (still, in 2015) doesn't save some modifications to the IDE until it shuts down, you need to shut down all other instances of VS and then lastly shut down the instance that you used to enact these IDE modifications for them to "stick". And, if VS 2015 is like previous versions, be prepared for the menu / toolbar modifications to simply go away one day, at which point you'll just have to redo them.
Is there a way to write VBA Code in Visual Studio. If not is there any other alternatives?
The best you can do is bend the office Visual Basic Editor (VBE) tool to your liking. If you stay in it's native environment you get the full power of error detection, Intellisense, live code running, etc.
My tips...
In the VBE go to Tools > Options > Editor tab.
Turn off 'Auto Syntax Check'. You still get code highlighted errors but no annoying popups.
Go to the Editor Format tab and change the Font to Consolas (Western), Size 11.
For code indenting install the awesome, free, Code Manager. It adds some sick keyboard shortcuts.
Make the Edit toolbar easily accessible for code commenting/uncommenting.
Use Rubberduck to add unit testing, source control, code inspections and refactoring functionality.
With those simple changes you end up with a half way decent, useful, and keyboard friendly environment to write your visually appealing code. :-D
VBA code for Excel can only be written inside Excel using the VBA IDE. VBA projects are stored as part of the Excel file and cannot be loaded into Visual Studio.
However, you can write VSTO (Visual Studio Tools for Office) managed add-ins for Excel using Visual Studio. The following MSDN page covers both developing with VBA and VSTO.
Excel for developers
You could also use the interop features of VBA to consume a (COM) object written in Visual Studio from your VBA code.
I've been looking for an answer to this question myself.
Best I've found myself is the option of exporting a Module ect from Excel with the code you've already written (or blank) and load that up in the Visual Studio Environment.
It doesn't offer much, but the highlighted text and auto indenting is nice and makes it much easier to read compared to the standard VBA environment.
Then once you're done just import it back into Excel.
There is a VSCode extension to do this.
It allows you to write code in VSCode and export it to Excel.
This extension is very useful when you develop in VBA.
Here's the link to download the XVBA extension
Edit :
As Peter Macej said in comment, this solution only works for Visual Studio Code not for Visual Studio
You can certainly add and edit a VBA file (.vb) in your Visual Studio solution, but the intellisense will be worthless/screwed up.
This extension for VScode would probably provide a much better experience: https://marketplace.visualstudio.com/items?itemName=spences10.VBA
If your goal is have your VBA code exposed to source control so you can track changes, then it's still worth it to include in your Visual Studio solution, but just store that VBA code in a plain text file and then use the Excel interop to load it into the appropriate module within the excel workbook, e.g.:
xlWorkbook.VBProject.VBComponents["ThisWorkbook"].CodeModule.AddFromFile(#"C:\PathToYour\VBAcode.txt");
And there are other methods to delete/replace code lines, etc....
You can try xlWings package for python and use it with VS Code https://youtu.be/xoO-Fx0fTpM
Is there a way to change the macro editor from this default one:
It feels like such a downgrade from Visual Studio 2010. Can I configure Office to use that instead?
no there is no way to my knowledge, VS.NET does not support VBA.
what you can do if you are creating a new word or excel file is create a managed office solution, having installed the VSTO 2010 (Visual Studio Tools for Office) you are able to create managed documents which are handled inside VS 2010 and the automation language is not VBA anymore but C# or VB.NET instead.
this is a viable solution for new files, for legacy files either you convert them if they are small or you keep old VBA code and old VBA editor as in your picture.
Mark I wish MS made a tool to convert from the old format to the new one! :(
There are things you can do to improve it:
Tools > Options > Editor :
Uncheck "Auto Syntax Check"
Tools > Options > Edit Format:
Customize the colors and font
Install the VBA Rubberduck:
http://rubberduckvba.com/
The RubberDuck does auto-indent for you. It also helps you with "unit testing, source control, from code inspections, and refactorings"
Basically, what I want to is be able to explore an ActiveX DLL.
I normally fire up VB 6, add the DLL to the "References" of the project, and use Object Explorer.
However, in this particular machine I can't install VB / VS.
I'm sure there's a tool out there that does this. Does anyone know of one?
Thanks
If the machine has Microsoft Office installed, you can go into the built-in Visual Basic for Applications IDE and load the object there:
Tools menu -> Macro -> Visual Basic Editor (or press Alt+F11)
Then when inside the VBA window, Tools menu -> References -> Browse to locate your DLL
and View menu -> Object Browser to view the object's content (or press F2)
I've used Microsoft's OLE/COM Object Viewer for this. It used to be installed with older versions of Visual Studio, and is still part of the Windows SDK.
It also seems to be available separately -- this is from an older version of the Windows SDK, but I don't imagine this tool has changed much recently.
To view the type information for a particular DLL or OCX, File, View TypeLib... is the option you're looking for. You can also dig through the Controls group in the main window to view details on a registered control. Right-click the entry for the control and click View Type Information to see details on the types and methods it exposes.
This will show rather more information than VB6 would. If you're looking at an ActiveX control, the coclass and dispinterface sections of the type library display are the things to look at.
(There's also an Expert Mode option in the View menu -- this will show you pretty much everything stored in the Registry to do with COM, OLE and ActiveX. This is generally rather a lot of information...)
Is it possible to download the component from that machine and examine it locally in Visual Studio? (That'd be my first suggestion.) (And BTW, the .NET versions of Visual Studio also feature a VB6-like Object Explorer which works nicely for this.)
Alternatively, and it's not free, but you might try ActiveXplorer. (I haven't tried this, but it looks promising.) (Discontinued)