r/MSAccess • • 26d ago

[SOLVED] Excel VBA issues

Hi,

Just wanting to see if anyone can shed any light on an issue I am having.

BACKGROUND: I have been on holiday for a week and returned with this problem. Yes IT, but yeah that's going to take weeks with this sort of query and and other help is appreciated.

THE PROBLEM: I have an access database I use to create a few reports in excel. Last ran on 20th Oct. Back yesterday and I am getting an error.

Access is pretty much saying the object Excel.Workbook no longer exists. Initial error was saying .SAVE is non existent. Begin commenting thing out and yes the class does not seem to exist. Just got a work new laptop and had not moved things onto it. Spend the morning setting it up, exactly the same result!

Ask colleague to run it, works fine (checked we are on the same office build just in case). So It seems to be a me issue, but on 2 separate machines. I have tried a lot of things like repair office, various windows fixes (dism cleanupimage/sfc (online said it might help, I doubted it)), unregistering and reregistering excel.exe (/unregserver etc), moved to late binding. Nothing worked.

Is it possible someone set something on my account that does this? If so why is excel.application still working. I guess I could rewrite to not use a separate excel.workbook as I think that is possible but again that will be a lot of changes and I just have never done it that way.

At the most basic level with most thing commented out having a

    Set oXLBook = CreateObject("Excel.Workbook")

Means I get the error "ActiveX component can't create object (as as said works fine for excel.application).

If you need more info just ask.

Thanks,

5 Upvotes

19 comments sorted by

•

u/AutoModerator 26d ago

IF YOU GET A SOLUTION, PLEASE REPLY TO THE COMMENT CONTAINING THE SOLUTION WITH 'SOLUTION VERIFIED'

  • Please be sure that your post includes all relevant information needed in order to understand your problem and what you’re trying to accomplish.
  • Please include sample code, data, and/or screen shots as appropriate. To adjust your post, please click Edit.
  • Once your problem is solved, reply to the answer or answers with the text “Solution Verified” in your text to close the thread and to award the person or persons who helped you with a point. Note that it must be a direct reply to the post or posts that contained the solution. (See Rule 3 for more information.)
  • Please review all the rules and adjust your post accordingly, if necessary. (The rules are on the right in the browser app. In the mobile app, click “More” under the forum description at the top.) Note that each rule has a dropdown to the right of it that gives you more complete information about that rule.

Full set of rules can be found here, as well as in the user interface.

Below is a copy of the original post, in case the post gets deleted or removed.

User: TheCarrot007

Excel VBA issues

Hi,

Just wanting to see if anyone can shed any light on an issue I am having.

BACKGROUND: I have been on holiday for a week and returned with this problem. Yes IT, but yeah that's going to take weeks with this sort of query and and other help is appreciated.

THE PROBLEM: I have an access database I use to create a few reports in excel. Last ran on 20th Oct. Back yesterday and I am getting an error.

Access is pretty much saying the object Excel.Workbook no longer exists. Initial error was saying .SAVE is non existent. Begin commenting thing out and yes the class does not seem to exist. Just got a work new laptop and had not moved things onto it. Spend the morning setting it up, exactly the same result!

Ask colleague to run it, works fine (checked we are on the same office build just in case). So It seems to be a me issue, but on 2 separate machines. I have tried a lot of things like repair office, various windows fixes (dism cleanupimage/sfc (online said it might help, I doubted it)), unregistering and reregistering excel.exe (/unregserver etc), moved to late binding. Nothing worked.

Is it possible someone set something on my account that does this? If so why is excel.application still working. I guess I could rewrite to not use a separate excel.workbook as I think that is possible but again that will be a lot of changes and I just have never done it that way.

At the most basic level with most thing commented out having a

    Set oXLBook = CreateObject("Excel.Workbook")

Means I get the error "ActiveX component can't create object (as as said works fine for excel.application).

If you need more info just ask.

Thanks,

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

4

u/maxquordleplee3n 26d ago

Probably reference related, first check your version of Access, then check for missing references.

1

u/TheCarrot007 26d ago

I am on 16.0.20430.20032 (365), but so is my colleague and it still works for him.

References are still there (VBA,Access 16, OLE, Office 16, AXDO 6.1, Excel 16), but as said sending my colleague the database with no changes still works.

6

u/jackofspades123 1 26d ago

Click them off. Close. Click them on and see if that does it

2

u/TheCarrot007 26d ago

Solution Verified.

1

u/reputatorbot 26d ago

You have awarded 1 point to jackofspades123.


I am a bot - please contact the mods with any questions

1

u/TheCarrot007 26d ago edited 26d ago

Close the window, or access completely?

EDIT: Well closing access does not work because I end up in VB with an error! Trying just the dialog box.

I think we have a winner! Most odd, I did not consider doing that because it worked fine on someone else's laptop

1

u/Breitsol_Victor 26d ago

Was there a switch to O365? Check the install.

1

u/TheCarrot007 26d ago

Has always been 365 (well for the last 6ish years).

1

u/George_Hepworth 5 26d ago

I agree that the symptoms point toward a reference problem. How are you dimming oXLBook, as a Object or as Excel? If you late bind by dimming as an object, does that help?

1

u/TheCarrot007 26d ago

I was early binding, though I changed it to late and that's when I got the error "ActiveX component can't create object" making it look like the workbook object is unknown.

1

u/George_Hepworth 5 26d ago

In that case, double-check that the way the object is being set up. It may differ slightly from the way the early binding was done and that could be the issue.

1

u/PerfectMachine1196 26d ago

Glad it's solved! What ended up being the fix?

1

u/TheCarrot007 25d ago

Oddly unticking the references i could, clicking ok and then going back in and ticking them again, ok again.

Then it worked! Which just brings more questions like why just me using it (another person used it ok on their laptop), and why same on my 3 backups untouched for nearly a year. Must have been something to do with an update but just affecting me as a user. Odd.

1

u/George_Hepworth 5 25d ago

The possibility that an interim update did change something significant is very real. Updates roll out uneventy, depending on which update channel you are on and other factors.

2

u/ebsf 3 26d ago

Check in the VBE to see whether a reference is set to Excel. I'm guessing, not. If that's the case, see whether you can set the reference, either by name in the list box, or by navigating directly to the relevant file. (I'm on my phone, so don't have that path or file name handy.)

1

u/SuchDogeHodler 26d ago

Check the security settings to make sure the vba model is trusted.

1

u/keith-kld 26d ago

If all efforts are made to the VBA reference but it still does not work, the issue may be derived from the libraries on Windows (or the framework, the environment and so forth). Please check it.