Trust Settings MS Excel [duplicate] - vba

This question already has answers here:
How to get rid of VBA security warning
(5 answers)
Closed 6 years ago.
Is it possible to programmatically disable ENABLE CONTENT Security message bar. I have a spreadsheet with some macros and some forms, however, even though i save the spreadsheet with the Trust Settings set to NEVER SHOW INFORMATION ABOUT BLOCKING SECURITY, it still pops up if i send the spreadsheet to someone else to open. I'm try to permanently disable it, or add some code to THISWORKBOOK_OPEN so that whenever it opens, it never prompts the user to click the ENABLE CONTENT button
Edit the problem i have is that i have a form tha is supposed to appear before users are able to use the spreadshet but in this case when they open it they firsy havento click enable content before the log in form appears .....is there a waynaround it?

No. Definitely Not. Never. Ever.

Related

How to force ms access form controls to generate code rather than macros [closed]

Closed. This question is not about programming or software development. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 6 months ago.
Improve this question
Access 2021 generates macros for form controls instead of vba code. How can I force ms access to generate code instead?
If you using the wizard for a "action" such as close form, you can't - they use macros.
However, If you adding a control with designer?
If you drop the control on the page - not use wizard, then you can right click say on a button, and choose this:
Then you get this prompt:
Then you get this:
So, you can choose macro, or VBA (code builder).
And if you get somewhat tired, you can CHANGE the default in Access to always use + assume you want to use VBA.
file->options->Object designers
And choose this option:
Now, when you right click on a control/button, and choose build Event, it will jump directly to VBA edit - and NOT assume you want to use a macro.
HOWEVER, this does NOT change the behavior of using button and control wizards.
That would be this setting:
drop the ribbon for controls, and un-check this:
However, quite a few mooms ago (access 2010???), they changed this to ALWAYS use macros for the button wizards, and you can NOT change this.
however, the kinds of operations are REALLY basic, and you should not care. Say to close a form, and do a few "simpleton" kinds of things.
Say, I have wizards "on", and I click on a button in the ribbon, and then click in the form.
You get this:
If I don't want a "wizard" at this point, just hit cancel. Right click, build event. (and with that default changed to use VBA - you jump right to code editor).
However, just keep in mind that if you use the wizard from above such as close form.
You get a macro.
You CAN change macros to VBA. And while somewhat of a face plant, the convert to VBA option is gray out when you open the macro like this:
So, close macro editor, and choose this option:
So, what I do?
Well, for a wizard button to close a form? Who cares - it just a close form - don't care if it is VBA or macro.
But, for all my button code that I write? Then I just hit cancel on the wizard prompt, or as per above, un-check in ribbon the user wizards.
but, many moons ago, you could have the button wizards generate VBA or macro. They to my knowledge for a very long time now - at least since 2010, maybe 2007, they generate macro code.
You can as noted, convert the code to VBA, or simple not use the button wizards.
Last but not least?
Well, if the convert to code is gray out, what is it for???
It is ONLY un-gray (enabled) WHEN you open a NON form/report macro.
So, for example, I choose this - a stand alone macro - NOT in a form
eg: right click on a macro like this:
Now I get this:
So, this is a stand alone macro - and you can thus use in the macro editor, the option to convert the above macro code to VBA if you wish.

Making a MS Word document "absolutely" read only

Is it possible in vba to make a document read only and in such a way as to prevent any user from making any changes to it?
The protect method for the document object allows you to make a document read only, but as soon as the user tries to edit the document it provides access to the Restrict Editing Pane which gives the user access a "Stop Protection" button.
I would like to prevent the Restrict Editing Pane from appearing.
Whilst it doesn't seem possible to stop the "Restrict Editing" panel from opening. It is possible to prevent the user from enable editing by adding a mouse hook and catching any mouse clicks within the Restrict Editing panel. Code in Delphi is
Hdl := WindowFromPoint (Mouse.CursorPos);
GetClassName (Hdl, clsName, 256);
GetWindowText (Hdl, wText, 256);
if (uppercase(clsName) = 'BOSA_SDM_MSWORD')
and (uppercase(wText)= 'PROTECT DOCUMENT') then {do whatever}
This catches any clicking within Restrict Editing panel and is not pinpointedto the "Stop Protection" button. I would assume it would be possible to drill down further to identify the button specifically, but it seems to me unnecessary to do so. Also, if the class name or window text changes then the function will fail.
Aside from being clunky and potentially not future proof, it does however work.

Password protected VBA but code still visible

I have an excel macro file(.xlsm), when I open the VBA editor, on the left panel I right click on VBA project XYZ and click on VBAProject properties, it prompts for a password. This indicates that VBA is password protected. However, I am still able to see the macro codes in modules/sheets.
Is that possible and if yes then what's the point here in protection?
Though I am able to see the code, when I try to add a reference, I again get that password prompt. Why?
That is because you or the author haven't clicked on Locked project from viewing while protecting the VBA Project.
Also you need to close and re-open the workbook for the Lock Effect to take place after Locked project from viewing is checked
Your Questions
Is that possible and if yes then what's the point here in protection?
Yes it is possible. The intention here could be to ensure that you don't make any changes to say references as you have already experienced. OR someone simply forgot to click on Locked project from viewing like shown above.
Though I am able to see the code, when I try to add a reference, I again get that password prompt. Why?
As mentioned above, since the VBA Project is locked, you cannot make changes like adding a reference.

Auto run good Macro before User Macro? [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
How to protect cells in Excel but allow these to be modified by VBA script
any chance to run a specific marco [GodMarco] before any marco [UserMarco] which fired by user?
CASE I
I have a worksheet, which have lots button to do different action by user.
I have normal cells to let user input data, and have hidden cells to do the dirty work.
And since user may user [arrow] or [tab] to circle through, I have to protect the sheet.
And made them not selectable.
And now VBA stopped.
I know I can add vba codes to unprotect and protect again and again, but I think it is stupid to add them to each marco.
So can it be something like GODMODE that before each marco fired by user, run GODMARCO1, and after user marco, run GODMARCO2?
[DONE, THANK YOU.] CASE II
Or can we get some cells not selectable by user but selectable by VBA?
THANK YOU VERY MUCH.
Open the VBA window (Alt + F11). In the property window of the sheet you want to protect you will see the "ScrollArea" property which will limit the area that can be selected by the user, set it to whatever range you want to make accessible to your users.

How to force user to deal with the Security Warning when starting Access 2007?

When a user start an Access 2007 database that have macros and vba, a security warning is shown. I want the user to deal with this warning, so if the the content is't enabled, the user should not be able to use the database.
Now I use a macro named AutoExec (opens a form that works like a menu), and that macro is run before the user deal with the security warning. But I want to check if the content is enabled and if not I will show a form that inform the user that they should enable the content.
So what I'm actually asking for is how do I do this:
If vba and macros is not enabled -> show form "information"
If vba and macros is enabled -> show form "start menu"
Ok, after a while I have the solution. Thanks for the answers who led me the right way.
This article from Microsoft is very helpful.
In the AutoExec-macro, I have two lines:
Line one: Conditions: [CurrentProject].[IsTrusted]=False and then I choose witch Form I want to open and in this case it is the "info about security warning form"
Line two: Conditions: [CurrentProject].[IsTrusted]=True and now open the "start menu form"
And that's all!
If the content is disabled, then you cannot check, since your code cannot run....
You might like to consider a start-up form ("information"). This will show without macros.
In addition, you can run some start-up code or a macro that closes the information form and opens the main form ("start menu"), if macros are disallowed, this will not run. However, I think you may get an unsightly warning.
EDIT
Set the timer interval to say, 100 and add a little code to Information form:
Private Sub Form_Timer()
DoCmd.Close acForm, "Information"
DoCmd.OpenForm "start menu"
End Sub
Just to add my solution -- I was just dealing with this issue.
By default, in database options have it set to open with form "notEnabled"
On this "not enabled" form, have some text, pictures, or what have you that lets the user know that he/she needs to 'enable content'.
In the on load event for this form, just put some VBA to open the actual form you want the user to be presented and close the "notEnabled" form.
This way, if the user opens the database without making it trusted, enabling content, they are stuck on the form that tells them how to do that. As SOON as it's trusted, the on-load event of the form will fire and redirect the user to whichever form you want, with content enabled.
If the user opens the database and already has trusted the file, they don't see the form telling them to make it trusted.
You can avoid this by setting the IsTrusted flag to TRUE in your AutoExec macro. See Transitioning Your Existing Access Applications to Access 2007 -- search for IsTrusted to get you to the heart of the explanation of how to handle it.
I don't know why people give suggestions that have not been tested yet. My solution is simple:
If: [CurrentProject].[IsTrusted]=False
RunMenuCommand: CloseDatabase
Else
If: [CurrentProject].[IsTrusted]=True
RunCode: (you run the code or macro you wanted to in the first place here)
This basically closes the database if the security warnings are coming on. If they are not, it opens just fine. The user that is the admin will need to decrease the macro security levels on the computer of whoever wants to access the database. This macro unlike others will actually run because it agrees with what Access wants.
You're Welcome!