Excel Macro to Create a new Excel workbook file. Use the following Excel VBA code to create a new Excel Workbook and save it as a given path as shown in the below code. Sub CreateNewExcelWorkbook Dim wb As Workbook Set wb = Workbooks.Add wb.SaveAs 'C: abc temp.xlsx' End Sub. Copy Array Values Between Arrays in Your VBA Projects. Count The Number Of Occurrences Of A Character Sequence In A String. Count Total Number of E-mails in the Outlook Inbox Using Recursion. Create a Category Tree in Access 2000 (Article) Create a Unique List from Column A (Excel Macro) Create a Word97 Document. Download Excel VBA macro examples. From this page you can download Excel spreadsheets with VBA macro examples. The files are zip-compressed, and you unzip by right-clicking (once the file is downloaded) and choose 'Unpack' or whatever Windows suggests. The following Visual Basic project contains the source code and Visual Basic examples used for calendar implemented in excel/vba. This is a calendar implemented in Excel using Excel Visual Basic. It includes one custom calendar implemented in VB and also the system calendar. VBA obfuscation is a set of techniques that hide the intent of an Excel VBA program without changing its runtime behavior. It is difficult to obfuscate complex VBA programs without breaking them. In addition, visible obfuscated source code can reveal valuable bits and pieces of information to a potential attacker.
Products that convert Excel workbooks into executables (.exe) most often limit Excel's functionality, depend on runtime DLLs and may trigger anti-virus warnings when executable files are distributed. Needless to say that executables cannot be loaded as native Excel VBA add-ins.
VBA obfuscation is a set of techniques that hide the intent of an Excel VBA program without changing its runtime behavior. It is difficult to obfuscate complex VBA programs without breaking them. In addition, visible obfuscated source code can reveal valuable bits and pieces of information to a potential attacker.
Compiled VBA Code Is Secure
Our Secure++ VBA windows application (written in Delphi) can convert macro-enabled workbooks or add-ins along the sames lines of an Access MDE/ACCDE file. However, our solution doesn't alter file extensions (.xlam, .xlsm, .xlsb, pptm, ppam). Secure++ files are normal OpenXML containers, which contain compiled VBA code only.
We believe that compiled VBA code is as secure as a Visual Basic 6 compiled DLL. If your VBA application runs in Office 64-bit, so will its Secure++ version (VB6 cannot run under Office 64-bit)
Simply put, I love the Secure++ VBA application! I have used it several times to protect VBA code in my addin files (.xlam). I work for a non-profit organization in their headquarters and my daily duties involve computation and calculation of complex financial analysis.
Though, by profession I am not a developer, I have been using Excel and VBA solutions for more than a decade. I develop custom solutions in Excel and other popular applications to increase the productivity of myself and that of my colleagues at work. One challenge I had, was that my custom user defined functions (UDFs) were poorly protected. The non-profit organization where I work, employs approx 7000 employees around the globe. I was frustrated when I learned that intruders were hacking my VBA projects. I like sharing my knowledge, but not my personal custom VBA solutions.
I could have wrapped my code in DLL, but I wanted a simple solution without any change to the existing addin file format (xlam) I was hoping that someday there will be a software that can protect VBA projects and make them unbreakable, and here is the Secure++ application! My dream has finally come true :-)
Secure++ VBA does exactly what it says on the tin and I love it. I have published my feedback online and referred several Excel community users to use Secure++ VBA, if they really want their VBA unbreakable.
From an Excel MVP (May 2015)
- Recover VBA projects from corrupted Excel workbooks, PPT presentations or Word documents
- Enable macro editing in Shared workbooks
- Copy VBA projects between workbooks easily
- Replace an unviewable VBA project with unprotected source code
- Remove all VBA macros from multiple files (Excel, PowerPoint, Word)
- Find out which macro-enabled files contain VBA projects without opening them in an Office application (Excel, PowerPoint, Word)
- Make VBA projects Unviewable to protect your code against password hacking software
It is possible to create an add-in that is used by many workbooks, but when the add-in is updated, some workbooks may fail due to changes. Ideally, any Office add-in should be tested with all workbooks that use it to be sure the change is safe. This could be quite a task assuming one could track everywhere an add-in might be used, especially since add-ins often have no reference within the workbooks that use them and there are no references within add-ins to the workbooks that use them.
That explains why some IT departments may shun add-ins. It comes as no surprise that a lot of end-users prefer to keep code and documents together in one neat package in order to insure all parts are present when the workbook is opened. In addition, coding changes can be fully tested with documents that use them.
Updating VBA macros within distributed workbooks remains a challenging task for Office users and IT departments.
The game-changing Macro Mover add-in powered by Ribbon Commander allows Excel users to move entire VBA projects from one workbook to another within seconds. Forget what you knew about exporting and importing modules from within the Visual Basic Editor (VBE).
The Macro Mover add-in exports the entire vbaProject.bin, including all of the project's properties (references, protection settings, conditional compilation arguments etc)
Here are the advantages of this next-generation add-in:
- VBA projects are moved across closed workbooks extremely fast, as workbooks do not have to be opened in Excel
- The Macro Mover add-in is compatible with any Office OpenXML macro-enabled file or addin
- Locked VBA projects can be moved without being unprotected, as easily as moving unlocked macros. No need to set library references in the target workbooks.
- The only file that has to be transferred between remote locations is the vbaProject.bin, which is usually less than 1MB in size
- VBA updates could be pushed to multiple workbooks at once in a batch process, even remotely
- The entire VBA project can be recovered even from a corrupted workbook (given that its VBA project is intact). Click 'Export Macros' and select the corrupted workbook, then import the exported vbaProject.bin to a new workbook.
- Workbooks with real or sensitive data do not have to be transferred back to developers for macro updates.
How To Recover VBA From Corrupted Workbooks
Excel found unreadable content in [filename]. Do you want to recover the contents of this workbook? If you trust the source of this workbook, click YesThe above message is shown while attempting to open a corrupted workbook in Excel 2010. Here is how to recover its VBA project and move it to a working file using the Macro Mover add-in, (given that its VBA project is intact):
- Export the workbook's vbaProject.bin
- Import the saved vbaProject.bin into a healthy macro-enabled workbook
How To Unlock Macros In Shared Workbooks
Shared workbooks can be horrible, because several Excel features are unavailable in them. Developers cannot write, record, change, view or assign macros, as VBA is unviewable. Users can only run existing macros that don't access unavailable features.
So until today, if you had to update macros in a shared workbook, you were out of luck. The only way was to unshare it, discard the change history, edit your macros and share the workbook again. Sometimes shared workbooks that have been made exclusive a couple of times lose data or settings or trigger odd errors.
The problem: change history is discarded every time the workbook has to be made exclusive
Here is what you have to do to unlock macros in shared workbooks:
If you want to unlock macros in an existing shared workbook then:
How To Avoid Personal Workbook Read-Only Warnings
If you try to launch multiple Excel instances while using a Personal macro workbook (Personal.xlsb), Excel will display a read-only warning. To avoid that pesky message, unhide your Personal.xlsb workbook and share it. Until now, the only drawback was that shared personal macros were unviewable and could not be be edited.
Unlock macros in your shared workbook as described earlier in this article and enjoy a shared personal workbook, in which you can add or change VBA code easily.
How To Remove Macros From Multiple Office Files
Do you have a lot of code in userforms and modules in a workbook and want to delete it all at once? Do you want to remove macros from several files at once?
Deleting all code manually can be time consuming. You can use VBA to delete unlocked code only, plus you have to trust access to the VBA object model.
The easiest way to remove all VBA code from a macro-enabled Office file is to save the file in a macro-free format. For example, save a .xlsb workbook as .xlsx
However you should not open any workbook that you suspect that it has malicious macros or code with bugs that may damage your data or PC. If you disable macros, then you are left with no choice other than to delete macros manually or open and save each file in a macro-free format.
However, the Macro Mover add-in allows you to mitigate security risks and work more productively:
Make VBA Unviewable To Protect Your Code From VBE Hacking
VBA is infamous for its weak security. Several password hacking tools can unlock any password protected VBA project. The current methods to password protect your code are either very weak and can easily be hacked with numerous detailed articles published all over the internet or quite complex.
Watch this Youtube video to realize how easy it is to regain access to a VBA project you forgot the password to.
We have put this VBA password removal code to the test with an unviewable VBA project created by the Macro Mover add-in. It comes as no surprise that this cracking tool CANNOT unlock the unviewable project.
Please ensure that you keep an unlocked backup copy of your code, as any unviewable project cannot become visible again using this add-in. The only way to update macros in an unviewable workbook project is to import a new vbaProject.bin
The Macro Mover add-in is exploiting the well known shared-workbook trick to create an unviewable VBA project. Unfortunately, the trick cannot be used with workbooks that have Tables in them. If you want to create a sophisticated unviewable VBA project, please read about Unviewable+ VBA.
Disclaimer: Unviewable VBA projects using the Shared workbook trick are not 100% secure against hacking. While VBA protection is enhanced in unviewable projects against a particular type of software, attackers may use additional sophisticated tools to access your code. Hacking tools evolve over time, so our findings may be correct only at the time of this article publication.
Unviewable+ VBA For Office & AutoCAD
The Unviewable+ VBA project is an attempt to once and for all protect your intellectual VBA property without external file dependencies from the lion's share of hacking tricks. What if you didn’t need to worry about others modifying or even stealing your code? With the Unviewable+ project, this thought is now a reality.
Click image to learn more about the Unviewable+ application
Click button to download the RCMacro Mover add-in for Excel 2007 or later
VBA add-in powered by the Ribbon Commander (RC) Framework