Use keyboard shortcuts from VBA to trust VBA object model - vba

I am currently trying to programmatically enable access to the VBA object model using macros, but I simply do not understand the answers that I have found through Google.
As such I decided to try using keyboard shorcuts. For example, in my language if I press:
Alt -> F -> I -> C -> TAB -> T -> I -> I -> I -> TAB -> V
Then I have successfully enabled the setting to trust the VBA project model.
Is this approach completely idiotic?
Is there an easier way to enable the setting with actual coding rather than what I am trying to do here (I can see cases where my method would likely unreliable)?
And if my idea isn't as bad as it looks, then is there a way to carry it out?
Sites visited:
http://wellsr.com/vba/2017/excel/macro-to-enable-trust-access-to-the-VBA-project-object-model/ (Understandable, but too unreliable)
https://blogs.msdn.microsoft.com/cristib/2012/02/29/vba-how-to-programmatically-enable-access-to-the-vba-object-model-using-macros/ (Might as well be gibberish to me)

This is highly discouraged. The whole idea behind trusting option is requiring user permission. Imagine how "secure" it would be if every macro could automatically trust itself.
Edit: though it may be possible with mentioned SendKeys method, you will still need a click from the user to enable macros, i.e. when they open your file.

Related

How to disable Formula Error Correction Prompt?

I am not very familiar with VBA and I have to perform a task that involves opening a number of Excel files. These are full of broken links and I don't have the time to change things. As I open each file, 5(!) message windows pop up, one after another, and to get rid of them I have to hit "OK".
One of the "OK" windows is this:
Wanting to avoid this, I have
Opened an empty Excel spreadsheet;
Hit Alt+F11 to launch the VBA editor;
Pasted the following code
Sub Appl_Display_Alert_Ex2()
Application.DisplayAlerts = False
ActiveWorkbook.Close
End Sub
And then hit F5 to run it.
However, while I thought that this applied to Excel as a whole, I assume it only applies to the single file, because I then went to open one of my broken files and the 5 windows popped up anyway.
Question: is there a way for me to avoid the "OK" message windows for all Excel files, whatever they are?
I would strongly advise against doing this, as it's not a good practice - generally it's better to simply fix the formulas/tables to avoid this error - but if you absolutely insist on doing this.
You can go to File -> Options -> Formulas -> Error Checking / Error Checking Rules and disable whatever checks necessary to avoid this prompt.
What I'd however recommend you to do instead, is to closely follow this article here and fix it the proper way instead!

Use HJKL in menus of JetBrains IDEs

Is it possible to use J and K when choosing a suggested auto-completion item? See the image below: I'd like to, maybe hold ALT or SHIFT (or in some other way differentiate between moving and typing), and use J and K to select the proper suggestion.
Is anything similar also available for moving around the menus (in Project view etc.)?
I was able to make this work by creating a shortcut ALT+J mapped to the Down key and ALT+K to the Up key.
You can move up and down in the popup without needing to move your hand away from HJKL to the arrow keys.
This also works in the Find in path window, though it does not work in the navigation menu.
Update: For Alt + K to work in the Find window since the version 2020+, one has to disable mnemonics in Settings, under Appearance & Behaviour -> Appearance -> Disable mnemonics in controls.
#Rok Povsic's solution is great and I used it a bit, but in some pop up menus like Intention actions, refactoring menu or usages the trick won't work.
So I used this Power Toys program from Microsoft to remap the Alt+J, Alt+K, Alt+H, Alt+L to arrow keys at windows level and now this works great everywhere around the IDE.
You can even specify only the app in which you want to override this shortcuts. For example for rider it will be "rider64.exe". You can find the name of the app you want to use in task manager under "Details".

Completely disable auto import in IntelliJ

The auto completion menu usually shows too many suggestions. For example, when typing "Double", there are 10 types with name "Double" popping up, from packages that I never imported.
I know I can exclude certain packages from auto import, but it doesn't solve the problem entirely. Even if I exclude package "java", it still shows types from javafx, sun, org, com, etc. How can I exclude all packages or disable auto import completely?
You can at least disable the completion auto popup:
File (menu) -> Settings -> Editor -> General -> Code Completion -> Autopopup code completion
For me, the automatic popup gets in the way of typing and navigating anyway.
Also, I'd like to enable
Editor -> General -> Auto Import -> Add unambiguous imports on the fly
Then whenever I really need it, I explicitly invoke one of the code completion variants: Ctrl-Space (Basic) or Ctrl-Shift-Space (Type Matching) or Ctrl-Alt-Space (Class name).

Kentico 8.2 content locking

We have a situation where the 'Check Out', 'Check In' and 'Save' buttons have disappeared from Admin: Pages -> Page/Design/Forms tabs. Users trying to access this all have admin rights and Settings -> Content -> Content Management -> 'Use check-in/check-out:' is checked. Content Staging/Logging is enabled (if that has any relevance). What could cause this? Thanks in advance for your help!
Try Resigning your macros, I've seen weird UI things happen because the macros messed up, including things as you described.
System -> Macros -> Signatures -> Sign all macros and "Update macro signatures"
Tell me if this helps!
Turning on "Use check-in/check-out" is one part of the solution. The other is putting documents under a workflow.
Thank you, good to know! It actually ended up being a change in one of the CSS files the caused the buttons to not display.

Is there a way to keep the VS 2010 VB.NET IDE from doing things that it thinks I want it to do?

Do this in VS 2010 with VB.NET:
On a blank line, type anything that isn't a variable, property, method, etc. I will use woo as an example.
Hit Enter or move the cursor up or down a line.
VS will add parenthesis to the end of it, turning it into woo().
Annoying, isn't it? Now insert foo in front of woo(), separated by a space like this: foo woo().
Move the cursor up or down (don't use Enter). VS turns it into foo(woo()), somehow drawing the conclusion that you want to pass woo() through foo(). What gave it that idea?
I know that the IDE isn't a text editor, but there are many times when I will want to paste in some text from a business requirements document or even some SQL and then comment it out after the fact. c# is great for this since it never assumes that I am trying to do anything, but the VB.NET IDE ends up parsing the holy love out of whatever block of text I paste into it and I end up having to edit out everything it added in.
Why does it do this? Can I tell it not to?
Unselect Pretty listing (reformatting) of code. You can find this under: Tools -> Options -> Text Editor -> Basic -> VB Specific