How to disable Formula Error Correction Prompt? - vba

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!

Related

Word Save Template command returning error

I recently discovered the blissful convenience of being able to use the File, Save command from within the VBA Editor window to save the currently attached template without having to actually be in the template or close out of Word.
I thought it would be nice to have this command available on a Ribbon Tab or the QAT or even a keyboard shortcut, so I first added the Save Template command to a Ribbon Tab. But when I clicked on the tab, nothing happened.
I thought perhaps I needed to tweak things a bit with a macro, so I recorded a macro and clicked on the command, to see what the VBA statement would look like.
It looks simple and straightforward enough, very similar to a bazillion other "ActiveDocument" macros I have stored that run without any issues:
ActiveDocument.AttachedTemplate.Document.Save
But when I run the macro, I get the standard "Runtime error" message, with no hint as to what is wrong.
I cannot find any documentation regarding this command in any of my source material or anywhere on Google, nor can I find any discussions about it.
Any ideas what's missing here? Thanks in advance!
As I discovered, and Cindy Meister confirmed, the following works:
ActiveDocument.AttachedTemplate.Save
It will work even if the template is closed. The version that you got from the Macro Recorder, ActiveDocument.AttachedTemplate.Document.Save works only if the template is open. The version above works whether it's open or not. I don't program much in Word, but it looks like a template's Document object/property is instantiated when the template is opened and otherwise is nothing.

VB.NET Copy To Clipboard Error

I really don't know what is going on. I used this code a lot of times, but for my current project I can't copy anything to clipboard without Catch ex As Exception which I don't like it cause it take so long until the content is copied to clipboard.
Does anyone know why I get this error?
You need to run your application as Administrator or open your Visual Studio IDE with option Run as administrator.
Don't forget to tell the type of data format you want to copy into Clipboard, after changing the text.
Clipboard.SetText("df", TextDataFormat.Text)

Can I get the VBA syntax check error without the automatic syntax check?

When I write VBA code, I tend to cut and paste variable names or other bits of code. This results in frequent syntax check errors that result in the message box popping up. That's annoying, and I'm aware that I can turn it off via Tools > Options > Editor > uncheck Auto Syntax Check.
This doesn't seem to prevent the VBA editor from actually checking my line - it still turns red. I don't mind that behavior, because it doesn't interrupt anything. And it does let me know if I do, in fact, have some sort of problem after I'm done with the line, which is nice. Unfortunately, I'm not always smart enough to diagnose the error on my own, and the text in the message box is actually helpful. But I've turned off the message box!
Is there a way for me to display that error, short of temporarily turning the message box on?
You can compile, with Debug>Compile, which will bring up the same message. IF there's more than one compile error you might have to deal with that one first.
This comment is for users of Visual Basic for Excel on a Mac.
I am using Visual Basic in Excel verion 16.14.1, (the latest version as of July 2018), as part of Office 365 on an iMac Pro, running High Sierra.
Under the Tools tab of the Visual Basic editor, there are only three choices:
References...
Macros....
VBA Project Properties......
None of these sub-menus lead to "Options", nor to anything which allows you to turn on and off "Auto Syntax Check"
Instead that option can be found in Excel ==> Preferences tab. However. checking or unchecking the box does not change the behaviour. In both cases, the text turns red on a syntax error, but in neither case does the annoying pop-up window appear.

Disable excel prompt about quality loss when saving

I am working on macro for my proffesion in the army - I make graphs of air force saftey.
I want to make my job easy so I want that the macro will change somethings - which it does right now and it will save the file and exit.
When I save the file it prompt about the quality loss and I want to bypass it.
Will
Application.DisplayAlerts = false
work?
I cant test it on my computer because it doesnt happen to me here, and I just came back from the army - I will be back there in 3 days, just want to be sure that I have the right answer...
If it wont solve my problem what will?
Thanks!
Although turning off the alerts may hide the dialog from you, I am in complete agreement with Jon. It will mask any and all other errors that you most likely want to see.
Instead of masking the issue you should resolve the root cause of the issue. That is, save the Excel Workbook in a format that can handle the newer features or remove the newer features that are causing the issue.
In the Workbook.SaveAs method you pass a parameter named FileFormat. This is a value from the XLFileFormat enumeration. There are numerous file formats to choose from here but I suspect that you will want the XLFileFormat.xlOpenXMLWorkbookMacroEnabled one. This is the latest format for Excel 2007 (Not sure about 2010).
Good luck,
Doug

Why does the VBA Editor open on its own sometimes?

I created a script in Outlook 2003 VBA that watches for new appointments, and sets them to tentative and no reminder as I create them. I find that seemingly at random, the VBA editor will open itself. It doesn't happen when I use the new script, but it did happen this morning when I un-hibernated my laptop, for example.
The editor doesn't pop up any runtime errors or highlight any lines in the script, it's just there as if I had pressed Alt-F11 to launch it. Sometimes I close other apps and see that it's been sitting back there for a while.
This behavior has only been occurring since I created this new script. Any ideas why this would occur?
As stated in, Microsoft Support Center:
"This problem occurs only if the Microsoft Visual Basic Editor window
is maximized."
Solution:
Un-Maximize Visual Basic Editor and close it.
And you are done!
If you have previously set breakpoints, it may be that you still have a phantom breakpoint. Try choosing "remove all breakpoints" and see if that clears the problem.
Check also that you have not chosen "Break on all errors" under options, and that your error handler is functioning properly.
Believe it or not, this is a known issue. Check out this MS Support link:
http://support.microsoft.com/kb/829059
I have the same problem and found it while I was looking for a solution. Since it gives no advice, I kept searching and came across your post. I will come back with an update if I find a solution.
The MS page linked by Jaquez hints at the answer; just make sure you don't run the editor maximized, and the problem should go away. If you restore it to a non-maximized state, then resize it to take up the whole screen, it should remember its position.
It's a pain if you only have a small screen, but on a normal large monitor it works fine, and solved the problem for me.
I have the same problem, except that it only occurs when I've gone in and unlocked the VBA project for editing and haven't restarted Outlook. It seems to open up when I get a new email (that's when my VBA runs) so basically I just have to restart Outlook and lock the project back up.
Sorry I don't know what's really causing it, but locking the VBA project should fix the problem...
My solution was to search for the .otm file of my VBA project. It was stored under data\microsoft\outlook. I closed Outlook and deleted the .otm file. Restarted Outlook and it was solved.
Just wanted to add that I was running into a phantom breakpoint issue with VBA in excel. Clearing all breakpoints did not work for me, but I resolved it as follows: Copy all content from offending module into a text file. Delete module. Re-create module. Copy back in all text. Save. Phantom breakpoint gone.