ExecuteMso error - vba

This question may have been asked before.
I have tried using ExecuteMso in VBA but returns Method or data member not found.
Not sure what I am doing wrong or if there is an issue using this code as using excel on a Mac. I have also tried this on a windows version of Excel however it is a very old version (if that makes a difference?)
Any help or tips regarding this would be great.
Thanks in advance

The following sample executes the Copy button.
Application.CommandBars.ExecuteMso(“Copy”)
Otherwise, post what you have tried and what is giving you the problem.

Related

BC30420 'Sub Main' was not found in 'quicktest4'. after finding that this error could be caused by a install fail I repaired visual studio

so I'm new to visual studio and I wanted to use the visual basic functionality of the program but when I try to compile and run my VB I get the BC30420 'Sub Main' was not found in 'quicktest4' error code. I looked around on the internet to see what could cause this and found that it could be and error with the install itself, knowing that I proceeded to use the repair function in the installer and got the same error. I've also tried deleting the entire program and reinstalling and got no change as well. I also read a post on this website saying that it could be something about the properties so I checked there and did not see anything out of place. Link: BC30420 'Sub Main' was not found error in a Windows Form app
Any help would be appreciated greatly, I really would like to actually start building stuff. this has been a two day ordeal so far.
If it involves adding code, please tell me where because this system is pretty foreign to me.
EDIT: Adding a screenshot of the quicktest code itself
code snippet
Check your properties. Sometimes it sets the initial form to main instead of form 1.

Excel VBA Run Time Error

I was handed a project at work, and when I run the macro, it comes up with this run time error:
When I go to debug the tool, it highlights this piece of code:
I looked at this webpage for help and the workaround says to change settings in Enterprise, and I have no clue what that is.
My questions are:
What is Enterprise and is that the simple work around to this?
What is wrong with that portion of code to make it have this runtime error?
Any help would be appreciated!!

"File not found" at the execution of any VBA code in Access 2007

I'm working on a big Access 2003 project with Microsoft Access 2007­. Recently, some users have started to experience problems with the buttons in my forms. For example, without any specific reason, clicking on a button or trying to execute any code will return the error:
File not found
There is no way to go into debug mode. When this happens the only thing to do is to restart the database. I tried adding the Stop command at the beginning of the executed block to try debugging it, but no code is executed at all. It's like a compilation error but it's only happening 5-10% of the time, which is really weird.
After some research, I found other people are having the same problem, for example this and this link. There are other examples too, with no real solutions yet.
My database can be okay for a week and then the problem starts to happen again. Half the time and users can't do much; they need to restart the database once or twice to get it back working, and after a few minutes the error might happen again.
Because this is Access 2007 and there are a lot of people experiencing this bug, I can't believe it isn't more documented.
What's the problem? Is the database somehow partially corrupted? What should I do? This is really annoying.
If I was in this situation one of the first things I would try would be to do a complete decompile+compact+recompile operation on the front-end database file, and then distribute that updated front-end out to the users to see if that improves things.
Detailed instructions on the decompile+compact+recompile steps are available here. Note: Be sure to read David W. Fenton's additional recommendations in his answer.
I had just experienced this for the first time. I had been making extensive coding changes in a form, and was required to reboot my PC without finishing debugging the code. When I opened the app, I immediately got the "file not found" message (it auto-starts a different form).
On a whim, I went to the form in question and commented out that entire module's code and the problem went away. After I went back in and uncommented that code, everything still worked as normal. I was able to continue debugging that code and lived for the rest of the day happily.
though this thread is over a year old I would like to share another very helpful observation.
This error "File not found:" may be caused by differing save behavior of Office versions and may not have anything to do with your code! In case of this error, try to open and save your troubled file in another Office version and it may work fine back in your main Office version.
Details:
Though programming VBA for years now, I had never had an unsolicited "File not found:" error. Weird also that the error message does not give a file name for the file not found. (Reminded me of another nasty error VBA sometimes shows on startup for no obious reason and erratically.) Luckily this error started after my first edits in PowerPoint 2010 after having tested the file in PowerPoint 2016. The error occurred when opening the .pptm but I had no startup procedure involving a file. So I've got the idea of some file in the .pptm zip archive not being found. Started to do a quick search on the internet and found only "shooting in the dark" suggestions. As I could start PowerPoint 2013 more easily (virtual machine) than PowerPoint 2016 (different Windows 10 boot partition), I tried to open the troubled file in PowerPoint 2013 and had no problems. I compiled the VBA project to check for error. Nothing. And save the file. After this re-saving in PowerPoint 2013, the file seems to work fine again in PowerPoint 2010 und did not show any problems after the first few edits, saves and re-opening. This being said, I wonder if PowerPoint 2016 saving is peculiar and if I can replicate/if I will run into the error again if saving the file again in PowerPoint 2016 and returning to PowerPoint 2010. (I'll make a note of this thread to add new insights once I worked with this file again in PowerPoint 2016.)
Hope this observation may spare many unnecessary un-/re-installations of Office and other desperate attempts.
Cheers!
A similar thing has just happened to me a couple of times with one of my .mdb front ends running in Access 2013, after the August 2019 update to Windows 10.
My DBs too have been through several versions of Access. On opening the database it says 'File Not Found' and throws up a public module (not one on which I have been working extensively recently), without opening the Autoexec (Switchboard) form. 'Debug, Compile' is possible and doesn't suggest any problem.
For me too, typing one space (or blank line or other character) anywhere in the code, and then deleting it, and saving, closing and re-opening seemed to provide a workaround, and all has been well for the last few days (I am the only user at present).
There is no one obvious module involved, although I will probably suspect the form module I have been working on most recently if the problem persists in a troublesome way.
Now, a few days later I have de-compiled, compacted and re-compiled the database, halving its size, so maybe that will have done the trick. I hope so.
I just had this problem. In my case, I think the issue is having a blank VBA module. I was moving procedures from one module to another and ended-up with a blank module. I couldn't delete the module manually and every time I tried to create a procedure to delete blank modules, I received the "File not found" error and the procedure I had just created was blanked out. I ended-up reverting to a backup.
The issue is just your references. One of the files for your references has been moved/deleted/updated. Remove and re-add your references to figure out which one.
I had a problem similar to this. A blank "File Not Found" error.
I turned off AutoCorrect and after clicking through several prompts/warnings which had me concerned, I then reopened the database and the error went away.
When reopening the database the problem was resolved.
I suspect this will fix many "File not found" errors which are probably related to the temporary link table losing a reference for whatever reason.
I had this same issue MS Excel.
On the user pressing a button a useless File Not Found error appeared.
I ran through all suggested above and no change or help.
COMPLETELY ACCIDENTALLY I removed a module that i use for updating the Application status. This also has some array storage within. However, on removing this module (and commenting out references to it within my code) it appears that the issue is now fixed across users.
One Issue, is I have the same Module name within several different deployment's of Excel Add-ins. I suspect that on first run Excel isn't able to automatically assume the difference between them.
I had noticed a WORK AROUND for the error in which you create a break point on the first line of code for the button in question and then resume on break - I assume that this helped Excel evaluate and namespace the modules as to not cause conflicts.
I had that problem and solved it this way: I eliminated the form where the vba code was and imported the same form from a backup file made before.
I found yet another solution (at least in my case): In trying to find the error, I tested the application I created on a co-workers computer. This somehow reset whatever went haywire in the file. Afterwards I was able to open up the file on my computer again and everything worked as it should!
EDIT: I have realized that the error, im my case, seems to have been connected in some way to my using SendKeys (see my attempt to automate a report here on SO).
Had the same problem. I stumbled on the fix by accident. For whatever reason, simply adding an on-click Event Procedure made everything better.
Open the form in design mode
Select an object on the form
Press F4 to display the object's properties
Event > On Click > dropdown > click [Event Procedure]
Then click the three dots, which will create a new event, and launch the Visual Basic editor. This will also add default code into the Visual Basic editor
Make no other changes
Save and close changes to the form
Restart the database
For what its worth, as I was wrestling with this issue, the error resolved itself in other ways, but none of them were repeatable.
I had this problem as well, and compact/repair did not fix it. In my case I had an old VBA module that was no longer used, and which referenced an object class that no longer existed. Removing the non-compiling code fixed the issue for me.
I have had this problem for many years now in access 2010. Always in the Autoexec form that opens on msaccess startup. I tried creating a very simple form that calls the original more complex form. To my surprise the more problem moved the the new simple form. By trial and error, I found that just editing the new simple Autoexec form the problem would go away, but turn up randomly months later ALWAYS after I had made programming changes elsewhere. Sometimes instead of the file not found error, I get just get a crash out of access - but the solution is the same procedure - make a small edit to the autoexec file (just add new blank line will do). My project has come through many versions of access (2000 -> 2010). If there was some way to automate the editing of my autoexec form, then restarting access - this would serve as a workaround. I have not found any way as yet.
I have had this problem for years in my access database. I tried all the above solutions an they all fixed the problem, only to have the problem reappear sometime later - always after VBA code change. I discovered that decompiling and then recompiling ALWAYS FIXES this problem, and is the quickest and easiest way to do so. So I have concluded that there is a bug in way Office only partly compiles after program changes like macros and VBA code changes. After a number of changes the system gets 'unhinged' and throws up the 'file not found' error. Reading thru the fixes users have found in this blog supports my theory. Nearly all these fixes would probably cause some sort and recompile the unhinged code.
MY SOLUTION
In summary I have found the following..
Doing a Decompile (without a recompile) will get rid of the error - but if the code is run on a different machine the error appears again.
Doing a decompile, then a recompile followed by a Compact and Repair results makes my app run on other machines with out any problems.
I had a class module - Class1 - that was not used. I deleted it and did a compact and repair.
Something happened that caused the name of the class module to stay in the Navigation Pane but the module as such was removed:
When opening the VBA editor I got the "File not found".
Impossible to delete the name from the Navigation Pane!!
When decompiling the project I got "An error occurred while loading 'Class1'. Do you want to continue loading the project?"
I did - now the Class1 was still in Navigation Pane when opening project again but now I could delete from the Navigation Pane.
After that the message about file not found no longer appeared.
FYI

VBA in Excel: "Can't find project or library" error when executing in 2007

Using VB for Excel in Excel 2003, I have no problems executing code with some non-declared variables:
numberOfBooks = 0
However, if I try to execute the same code in Excel 2007, I get a "Can't find project or library" error message.
I looked at Tools > Options and I don't have checked "Require Variable declaration". In Excel 2003 I did not use Option Explicit
What am I doing wrong? Thank you very much.
I have seen this advice (check references) a number of times and it makes sense!
However, when the fault: "can't find project or library" develops, you are in run mode and I cannot get out of it?
Waht am I missing?
I'd definitely second Daniel Cook's suggestion of checking your references list; that may be it. However I've come across some situations over the last couple of months where that error will occur in an Excel 2007 even if there is nothing wrong with the references. In part it seems to relate to the security updates that were released in August 12 ( http://technet.microsoft.com/en-us/security/bulletin/ms12-aug ). It caused some breakage in the mscomctl.ocx. The problem and (one) resolution (basically, re-registering the .ocx) is discussed in this IBM link which relates to an Excel add-in for an OLAP product called TM1: http://www-01.ibm.com/support/docview.wss?uid=swg21608271. (The error messages aren't the same as the ones that you've been getting, but I DID get your error messages on another add-in that I wrote which were not missing any references, and it turned out to be the same problem.)
The other thing I'd suggest doing is a purge of your .exd files as discussed here: http://support.microsoft.com/kb/290537 I've also found that those can cause bogus library errors, particularly after a version upgrade.
As for anything else you're doing wrong, well, personally I tend to skin anyone who works for me without using Option Explicit. 8^>
One of our companie's excel-macros (which ran quite frequently without any issues so far) all of a sudden came up with exactly the same error.
We didn't touch the code for like forever. And I honestly have still no idea what actually caused this error. Mistery Microsoft maybe? Anyways.. I finally were able to fix the bug.
Even though "Require Variable declaration" was disabled and Option Exlicit was not set in my case, declaring the variable first did the trick for me:
Dim numberOfBooks As Integer: numberOfBooks = 0
I hope this saves some headaches.

New Line Not Working on Windows Notepad (SAP ABAP)

Tried CL_ABAP_CHAR_UTILITIES=>CR_LF, CL_ABAP_CHAR_UTILITIES=>NEWLINE.
Both work on NotePad++ and Excel 2010 but not on Notepad.
Any hints?
The reason is that I made a wrong definition of CR_LF. Please check my blog for the detailed explanation.
http://www.dsun.us/node/60
I made a similar mistake yesterday. I think I need to take a break now.