Word VBA unhandled error not displaying a message - vba

I have a Word Template with VBA.
Wherever I need to I handle my errors with either a "On Error Resume Next / On Error Goto 0" round a call to a collection that might fail, say, or a full error handler (On Error Goto label: / Resume exit_label:)
Tools Options is set to Break on Unhandled Errors
I have found that for this template (only it seems) that unhandled errors are not being reported. The VBA code just stops running without telling the user anything.
I have tried exporting all VBA modules / forms, saving the template as a .dotx, closing and reopening then saving as a .dotm again and adding the code back but same problem persists.
Other templates for this client work fine. A deliberately added delete for a non-existent bookmark causes an error to be shown. The same delete call is ignored by the iffy template BUT the code stops running so it isn't doing Resume Next.
If I add a full error handler to the procedure concerned it does error and reports via my msgbox code.
In some respects this wouldn't matter, anywhere I am expecting errors to be a possibility I handle them but I have a certain amount of code that deals with images in headers and they are prone to errors. At this point I want the code to error where they happen so I can analyse how to get around the error, just telling the user isn't going to get the template working. What I have at the moment is the code "dying" and it is very hard to track where without putting in loads of debug statements and seeing where they stopped.
Has anyone seen something like this before? Could I have set something for this template specifically to tell it to not error on unhandled errors?
Other templates on the same machine error quite happily.
The template is very complex so I don't have the option to make it from scratch. Turfing out the VBA and putting it back didn't fix it. If I have to I can add handlers for all procedures but that shouldn't be necessary as errors won't happen once I have tightened up the code.
Any help really appreciated - for a few days I thought it was just VBA dying when working with images, now I really it is something more general than that.

Ok. I have found the source of the problem.
I had used a couple of standard procedures we have in various projects for conveying busy/not busy to the user - we call them InterfaceOn and InterfaceOff. They change the cursor, switch off screen updating, etc.
One line for the Off proc is "Application.EnableCancelKey = wdCancelDisabled".
I hadn't realised how severe that line is, it appears to stop the errors being reported and the code just dies. The help for it warns it is risky but doesn't explicitly state that it'll kill VBA on an unhandled error.
The InterfaceOn procedure has the line that reverses the EnableCancelKey restriction.
These procedures are used a lot so I am surprised this issue hasn't shown up before. Have removed the EnableCancelKey lines for now. No particular need to be that dramatic with this project.

Related

RDLC report randomly crashes application with compiler error -1073741502

The error as seen in the image is a compiler error -1073741502. I have searched SO and Google with little success. Tried to debug the process and was not able to determine what the issue is causing the error. The error has been occurring for some time and is random with no apparent pattern in the data or operation. This is also in a VB website using .net 4.0. The report RDLC has been recreated 2 times to see if the issue would be resolved but was not successful.
The only way to get the application to continue past this error once it occurs is to do an app pool reset. This is something we would like to avoid doing for obvious reasons.
Any help and suggestions are appreicated.

CreateObject("ADODB.Command") - Run-time error '429': ActiveX component can't create object

I have an old Access solution that includes opening a connection and inserting some lines in a SQL database. I had to make a very small change that had nothing to do with that connection. After the change I compacted the database.
The solution works normally for me, but the person that normally runs it is getting the Run-time error I outlined in the subject. I had another user try and also got this error. It seems I am now the only one that can run this, yet I did nothing to the code or the access db as a whole that I can see explaining this.
The button they press that triggers the error:
Sets a variable as ADODB.Connection
Defines the connection string
ERROR TIME: Then it runs a function that executes a stored procedure using that connection. The error point is showing as occurring at the top of that function, when it attempts to CreateObject("ADODB.Command").
Run-time error '429': ActiveX component can't create object
Can anyone offer anything as to why this user that could work with it suddenly can't despite the same security, same machine, etc.
Sigh... Thanks for the responses. It turns out to be our security software and the fact that I moved the solution to a different location. Out of sight out of mind. I forget that I have some exemptions setup for myself, so I didn't see how it could be that. I just need to learn to check that stuff first.

Runtime closes when I use DoCmd.OpenForm

I have a form with a button which opens a new form to add a new record to a table.
In Access on my PC (full version), everything works.
When I try to run it on a server with Access Runtime, I get an error saying something like:
this application has stopped working due to a runtime-error. The
application will now be closed
(I have the Dutch version, so I hope this comes close to the English dialog box message).
I debugged the VBA, but that doesn't seem to be the problem.
It has worked before:
Private Sub Knop62_Click()
DoCmd.OpenForm "Machines Toevoegen", , , , acFormAdd, _
acDialog, OpenArgs:=Me.Installaties_Id
End Sub
Well any un-handled error in the runtime will spit out the error message, and then as you experienced exit the application.
there are a good number of ways to approach this:
Improve error handling - make sure you don't encounter any un-handled error. I find this can be a LOT of work.
Another way? Compile your application down to a accDE. When you use a accDE, not only does the runtime ignore errors, not only does it NOT shut down?
It also means that all of your local and global variables are NEVER re-set. so global vars, and even global reocrdsets or anything else will retain their values, and do so even with errors. As a result:
Your application runs like a un-stoppable fright train.
Your local and even global variables retain their values. This allows use of application wide settings and variables that never re-set. And no re-sets ever occur even for un-handled errors. They remain intact for the given session (since the time the application was launched).
So, I would try running your application as a accDE on that server. It will not only become vastly more reliable, but it will also not shutdown on un-expected errors and even better it will retain the value of variables even when having encountered errors.
So it looks like you have some un-handed error. You can go on a treasure hunt to find this error, or just try a accDE in the meantime, and perhaps in the new years you might eventually track down the error or issue. But until then, just compile your application as a accDE.
To compile:
First, from VBA editor (just hit ctrl-g). And from the menu bar choose debug->compile. You MUST ensure that no compile errors exist before the next step.
If above compiles, then from UI (main ribbon), go file->Save and publish
From that panel, choose Make ACCDE.
Access will compile your application into a "access executable". Now try running this application with a accDE file extension on the other computer.

Getting Error 'HasFile' is not a member of 'FileUpload' VB.NET

I randomly get an error saying HasFile is not a member of FileUpolad.
I'm using a file upload button to upload images to a server. This usually runs; however, every once in a while it errors out. Sometimes the error is caught by Visual Studio during run time, other times it will be a Server Error in Application. Compilation Error when I load the page in debug mode. I've check dependencies and everything seems to be fine. Even the IntelliSense brings up HasFile with I am writing the code.
Usually re-writing the line or restarting Visual Studio resolves the issue, but it keeps coming up randomly.
I happened to figure out what the problem was. Since it was my first time doing this I had a test class in the solution. The test class was named FileUpload. Rookie mistake. I can't believe I didn't catch that earlier!

VBA code rushing on debugg mode while interacting with SAP

I'm having some issues with my code that I wasn't able to find anywhere.
Issue: While debugging my code, running it line by line with F8 in Excel, at some specific points excel does not wait for the application with which it's interacting to finish and proceeds to execute the rest of the code.
What is the macro: It's an a macro to automatically input information on SAP, in this case VA02. I do belive that this question is more VBA related than SAP related thus I'm posting here and not on SCN.
Where the problem occurs: The issue only happens when I'm changing the partners numbers in the Partner tab(either header or line item level). I've also saw this happens whenever I was trying to add something on the Conditions tab.
What error does it cause?: None, that's the odd part. While debugging, after I execute the line to change the Bill to Party for example ( Only change the number, no Enter or any other key is send) the code keeps running and execute the next lines. The even more off thing is that SAP seems to still be processing some of the changes but the VBA code keeps running without errors, meaning that SAP is not on the screen its showing.
So, if there's no errors what you want?: Well, while in regullar run mode it work flawleslly, this issue really makes it very hard to debug, forcing me to put a breakpoint in every... single...code...line...
What have you tried?: I've looked into Async and forced sync, no avail. Also looked in something related to Background Refresh but I guess that's only for query connections, I tried it with SAP GUI connection but also didn't worked.
Hope anyone can shed some light on this subject, maybe saw this previously. I will try to test on a peers computes but didn't had the chance yet, will post my findings after.
Thank you for reading and maybe replying =)
This is just a pice of the code as it's huge, I've noticed the problem is different parts, always the part that's inputing info on SAP. My peer write similar codes, that do the same thing on the same fields and he never got this erro so I think it might be related to excel somehow
'Bill site
Connection.findById("ses[" & Sesn & "]/wnd[0]/usr/" & ref & "/subSUBSCREEN_PARTNER_OVERVIEW:SAPLV09C:1000/tblSAPLV09CGV_TC_PARTNER_OVERVIEW/ctxtGVS_TC_DATA-REC-PARTNER[1,1]").Text = Dwks.Cells(2, "N")
For this program the erro usually start on this line, but on other ones i've seen it start on different ones. There's nothing special about this code line, i've used it many times. What comes before it is also pretty standard, just the SAP connection. I'm avoiding post the code here because I'm sure that this is not the cause of the problem, is the same sintax i've always used, with the same elements. This is something excel related.