I have created VBA coding in a workbook and created a macro button so that the vba code will be available to other workbooks.
But while running the vba code using macro button in other workbooks the original file opens again.
Is there a way to avoid opening the original file?
Related
My problem with Excel's VBA code protection:
In my current project, I wrote some VBA code (in WB1) that shall produce a new workbook (WB2). In this new workbook, a button (B2) is created. This button shall execute some code, when pressed. The macro that shall be executed is copied from the original workbook (WB1). This all works fine, when the VBA code in the original workbook (WB1) is not protected.
However, when I add protection to the VBA code in the original workbook, the module that contains the macro is not copied into the new workbook (WB2). And thus the button (B2) has no functionality.
My question: Has anyone of you run into the same problem and is there an other solution than removing the protection from the original workbook's VBA code?
I've been using ADO to process many Excel .xls and .xlsx workbooks without any problems. Recently I tried to process a .xlsm workbook to load to an Access database. The workbook contains several macros that are run every time a user opens a desktop version of Excel. The macros update "yesterdays" data with "todays" data. Unfortunately when I read the workbook programmatically ADO is returning "yesterdays" data. This means to me that the macros are not running when I open the workbook with ADO. Any suggestions. Hope I don't need to rewrite the code to open an instance of Excel to handle the workbook.
ADO accesses only the data saved in the workbook. Nothing vba (or any other) code does dynamically when the workbook is opened in Excel is available. Excel macros can only run when the workbook is open in the application interface.
Either your process needs to duplicate what the macro(s) are doing in order to update the sheet data or, yes, indeed, you need to first open the workbook in the Excel environment and execute the macros, then SAVE the changes to the workbook.
I recorded a macro in Personal workbook, saved the file that I recorded with .xlsm. Then closed this workbook.
I assume that I can reuse this macro in other workbooks.
Next day I open a new work book trying to use the macro that I created yesterday. the Macro list/menu shows blank. the macro that i created yesterday is not there.
I tried to created a few ones, sames process but the new macros are not saved to use for new workbook. Can someone shed some light?
I use excel 2007
The VBA created in an Excel sheet that is embedded in a Powepoint presentation is not saved.
I have a Powerpoint file, in which I have Inserted a Chart, thus creating an embedded Excel Workbook.
I have tried adding some VBA to said embedded Excel Workbook. IT all worked fine and my VBA worked as expected.
Until I closed the embedded Excel file and tried reopening it (by right clicking on the Powerpoint Chart and clicking on Edit Data). After reopening it, all of my VB was gone.
I suspect it has something to do with the embedded Excel file not being Macro enabled, but I can't figure out how to change this.
(Happy to provide a sample file if required)
How can I write macro in Excel that will work (to run with shortcut) on any excel document which I will open?
Is this possible?
You need to add your macros to Personal.xlsb in order to make them available to all the excel files. Choose Personal Macro Workbook in Record Macro dialog to do this quickly.
Source: http://office.microsoft.com/en-in/excel-help/copy-your-macros-to-a-personal-macro-workbook-HA102174076.aspx