If TextBox1.Text = "" Or TextBox1.Text = "False" Then
msgbox("Filename invalid. Try again.",vbOKOnly)
I'm getting "Compiler Error: Expected: =" error message.
To do this, click on 'Tools' and then click on 'Options'. In the options dialog box, make sure that the 'Auto Syntax Check' option is enabled. If the 'Auto Syntax Check' option is disabled, VBA will still highlight the line with the syntax error in red, but it will not show the error dialog box.
The “On Error Resume Next” is the error handler statement when we need to ignore the known error. If we want to ignore the error message only for a specific code set, close the On Error Resume Next statement by adding the “On Error GoTo 0” statement.
Microsoft is finally planning to block Visual Basic for Applications (VBA) macros by default in a variety of Office apps. The change will apply to Office files that are downloaded from the internet and include macros, so Office users will no longer be able to enable certain content with a simple click of a button.
VBA has fallen out of favor because it hasn't kept up with the modern demands of a programming language. It has hardly changed since it was first introduced in 1993. Other languages have continues to evolve and newer languages have appeared to dominate the landscape.
It's because you can only call Sub
s either with Call
or without parentheses in VBA. So change it to:
MsgBox "Filename invalid. Try again.", vbOKOnly
Or, if you like this style better:
Call MsgBox("Filename invalid. Try again.", vbOKOnly)
(And the reason you get the error is because it expects you to assign the result to a variable, hence it expects an =
.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With