QTP Code for permanently enabling MACROS - excel

I have a QTP script which opens an excel sheet and update some of my results in the excel work book, but the excel has macros, so everytime when i runs, the alert box asking whether to enable macros pops up.
So i need a QTP script which will premanently enable macros.
Kindly help.

You can't use QTP script to enable macros permanently. Another work around for this is to go for trust center settings in Excel. Here you have option to enable or macros or you can disable macros without notification. Once this is done excel won't show any notification to enable macros. You may need to check the "Trust access to VBA project object model"
Assuming that you are using Excel 2007: To access the trust center settings click the office button >> Excel Options >> Trust Center >> Trust Center Settings >> Macro Settings
Note: Its not recommended to enable macros permanently as it may compromise your security.
In addition you can open excel files in background using QTP. Try doing that and check whether the enable macro pop up create problems.

Related

Are there Admin settings for enabling/disabling the macro recorder in Excel?

After activating the Developer tab on the Excel ribbon, I noticed the Record Macro, Visual Basic, and Macros button's are disabled. I have been installing macros to the Personal.xlsb files for years and this is the first time I am unable to create the Personal.xlsb file using the Record Macro button.
Is there an admin setting, perhaps at install that would turn these features off? This issue is isolated to a single new user at present.

Enable macros with pop-up bar/dialog box rather than "File" menu button

It appears that MS Excel opens macro-enabled workbooks in one of three ways:
A pop-up bar that includes an "Enable macros" button;
A pop-up dialog box that includes an "Enable macros" button; or
No pop-up at all with a hidden "Enable Content" button maddeningly hidden within the "File" menu under the "Info" section.
Is there any way to force Excel to use a pop-up notification that always allows the user to automatically enable macros with the convenient click of a button? This is especially critical given that I have macros that run automatically when the workbook opens. However, under the third option mentioned above, the user would never know to click the "Enable Content" button in the File>Info menu.
Any help would be greatly appreciated!
Well you cannot influence this behavior in any way with your Excel file because it is part of the VBA security.
The yellow bar "SECURITY WARNING Macros have been disabled." with the "Enable Content" button is the default way how Excel tells you that macros are disabled.
The pop-up dialog box comes up only if the Visual Basic Editor is also open while you open a workbook.
"File" › "Info" option always works additionally to (1) and (2) so at least (1) or (2) should trigger too. If nothing pops up then the user probably chose one of these security settings:
"Disable all macros without notification" or
"Disable all macros except digitally signed macros" and your macro isn't signed
For more info see: How To Enable Macros In Excel: Step-By-Step Guide To Dealing With 3 Common Scenarios
A good alternative would be to digitally sign your code with a officially trusted certificate so users would not need to activate macros. They would only once need to trust your certificate on each computer. (If it is a company environment use GPO to trust the certificate on any company computers automatically).

Recovering datas from an Excel/ActiveX spreadsheet

I'm having the following issue: I've an Excel spreadsheet with a lot of VBA codes and ActiveX controls, including RExcel formulas.
The Excel version is 2007.
When I try to open this file, Task Manager says Excel isn't answering and something starts like if Excel started running endless codes; I deactivated each control and it still seems broken.
I would like to recover at least some formulas I've written in that spreadsheet, but this is actually impossible by opening the spreadsheet in conventional way.
Could you tell me how I can "read" formulas and text in that spreadsheet without opening it by Excel?
Thanks,
Indeed have calculation set to manual for a start.
Now set your security settings such that macros and activeX are disabled:
Excel Options > Trust Center > Trust Center Settings... > Macro Settings > Disable all macros with notification
For ActiveX I am not sure if there is a menu in excel-2007 like for macros, but if there is make sure it is set to not run as well.
Now you can open your excel workbook and it will not run your macro's and shouldn't auto calculate or update!
ADDED: I have had something like this in the past and this is what worked in 1 occasion: install an other office excel application, like open office (the calc application has the excel functionality) and see if it opens in that application. Then if it does, save the file (under another file name) and close it. Open the new file under MS Office Excel, and see what is still recoverable.
Good luck!
use a tool like 7zip to extract the files. the sheets/formulas are in the .xml
the code in a macro enabled spreadsheet is in a .bin file
this can be read with MalOfficeScanner

Quick Access Toolbar Customization: Selecting Macros causes Excel to crash

Running Office '10 on Win7
Experience: Some VBA experience, no XML experience
Hi,
I have two issues and an answer to the first may render the second mute.
Q1) Is there a way to get macros in locked add-ins to show up in the QAT macros drop-down? For example, I am running Hyperion and the essexleqd.xla and essexcln.xll add-ins are running. At least some of the macros for these add-ins are visible in the QAT macros drop-down, even though the add-in itself is locked.
Q2) Situation: Excel application is open, but there is no active/visible sheet open. When I go to customize QAT and then select macros from the drop-down, I get an error message and Excel crashes then restarts. Has anyone else encountered this, or know why this happens and has a fix?
Background:
I have a simple add-in that I want to distribute. I have locked it for viewing, but this means that I cannot create a QAT button that references the macro because the macro from the add-in is not visible in the QAT macros drop-down. I have read here (http://www.fontstuff.com/vba/vbatut03.htm) that this happens, but that I should be able to write in the name of the macro somewhere and the button will work.
Q1)
This article should help you.
How to: Create a Custom Menu That Calls a Macro
Q2)
I would guess that they crash because they can't handle that there is no active worksheet open. You probably have to start Excel by opening an empty file in order to workaround the issue.

How to permanently allow macro for a trusted worksheet?

I've created a worksheet which is shared amongst my colleagues with a real simply macro to show/hide rows but everytime either I or one of my colleagues opens it they get prompted to Allow marco - is there anyway for them to permantly allow this macro?
You'll want to digitally sign the project. Microsoft's information about how to do that is here: http://office.microsoft.com/en-us/excel-help/digitally-sign-a-macro-project-HA001231781.aspx
You need to change a setting in Macro Security within Excel so that your colleagues don't have to respond to a dialog box every time. Be advised, though, that when you allow macro code to run automatically, this can unsuspectingly open you up to malicious code in other Excel workbooks.
The location of the settings for Macro Security is different from versions 2003 and 2007 of Excel. In 2003 and previous, I believe the setting is visible in Tools > Macros > Macro Security. From there, you would change the security level to low. In Excel 2007 (and probably 2010), the setting is visible in the Developer tab on the ribbon (which you might have to make visible by toggling a checkbox in Excel Options). From the Developer tab, click Macro Security and chose Enable All Macros.
The above is the simplest way for your colleagues to make a change to their system, but a better way, as others suggest, would be to digitaly sign your own work so that your colleagues don't have to open a potential security hole on their own system.

Resources