# Excel command VBA not working

**URL:** <https://community.easymorph.com/t/excel-command-vba-not-working/3894>\
**Category:** Server (Hub) / Explorer\
**Created:** [September 12, 2022, 11:37am UTC](https://community.easymorph.com/t/excel-command-vba-not-working/3894 "2022-09-12T11:37:05Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![ruud.vanmiddendorp](https://community.easymorph.com/letter_avatar_proxy/v4/letter/r/b9bd4f/32.png) [@ruud.vanmiddendorp](https://community.easymorph.com/u/ruud.vanmiddendorp)\
**Post date:** [September 12, 2022, 11:37am UTC](https://community.easymorph.com/t/excel-command-vba-not-working/3894/1 "2022-09-12T11:37:05Z")

</div>

Hi,

Strange case here. When I use RDP to log in to the EasyMorph server (Administrator account) the process works fine with the Excel VBA command. But when run as a job it fails. It does not seem to open the Excel file. Excel has been installed of course (Office 2021 Home edition).

The EasyMorph service uses account 'Local Service'. And this account has been given acces to the Excel file. I've tested with worker Administrator and Local service. Both fail with the same error.

This is the logging:  
12-09-2022 13:34:16 000041 ERROR Run completed with 1 errors:  
12-09-2022 13:34:16 000042 ERROR Error: Microsoft Excel kan geen toegang verkrijgen tot het bestand C:\EasyMorph\Local space\test.xlsm. Er zijn verschillende mogelijke oorzaken:

• De naam van het bestand of het pad bestaat niet.  
• Het bestand wordt gebruikt door een ander programma.  
• De werkmap die u probeert op te slaan heeft dezelfde naam als een werkmap die reeds is geopend.  
12-09-2022 13:34:16 000043 ERROR Source: action "Excel command", table "Table 1"

Thanks and regards,  
Ruud

---

<div class="post-metadata">

**Author:** ![dgudkov](https://community.easymorph.com/user_avatar/community.easymorph.com/dgudkov/32/5_2.png) [@dgudkov](https://community.easymorph.com/u/dgudkov)\
**Post date:** [September 12, 2022, 11:53am UTC](https://community.easymorph.com/t/excel-command-vba-not-working/3894/2 "2022-09-12T11:53:01Z")

</div>

Hi Ruud,

For those of us who don't speak Dutch, what do these error messages mean, roughly?

---

<div class="post-metadata">

**Author:** ![ruud.vanmiddendorp](https://community.easymorph.com/letter_avatar_proxy/v4/letter/r/b9bd4f/32.png) [@ruud.vanmiddendorp](https://community.easymorph.com/u/ruud.vanmiddendorp)\
**Post date:** [September 12, 2022, 12:20pm UTC](https://community.easymorph.com/t/excel-command-vba-not-working/3894/3 "2022-09-12T12:20:01Z")

</div>

Yes, of course.

It's quite a basic default error message without many details.

Microsoft Excel can not access the file. There are several possible causes:

- The file name or path does not exist
- The file is being used by another program.
- The workbook you are trying to save has the same name as a workbook that is already open.

I've ruled out these possible causes. But still it seems EasyMorph cannot acces the file.  
The file is located on the C: drive. A 64bits version of Excel is installed on the server.  
I've used this article to troubleshoot, but unfortunately without result:

> [@Running VBA Macros from the Excel Command action](https://community.easymorph.com/t/running-vba-macros-from-the-excel-command-action/3149#tips-for-running-the-excel-command-action-on-server-11):
>
> With the release of EasyMorph version 5 comes an amazing new action called Excel Command which allows for running precreated Excel macros – subroutines or functions – from with a workflow, using the “Run VBA macro” setting. This option opens up new potentials for processes outside the scope of EasyMorph like applying complex formatting, inserting or formatting objects (charts, pivottables, shapes, etc.), or triggering an Excel-based reporting process. The sky’s the limit when you can have a co…

---

<div class="post-metadata">

**Author:** ![dgudkov](https://community.easymorph.com/user_avatar/community.easymorph.com/dgudkov/32/5_2.png) [@dgudkov](https://community.easymorph.com/u/dgudkov)\
**Post date:** [September 12, 2022, 5:41pm UTC](https://community.easymorph.com/t/excel-command-vba-not-working/3894/4 "2022-09-12T17:41:11Z")

</div>

Does the Server service account have access to the folder where the file is located? Note that the default LocalService account has fewer permissions than an Administrator.

---

<div class="post-metadata">

**Author:** ![CraigT](https://community.easymorph.com/user_avatar/community.easymorph.com/craigt/32/3839_2.png) [@CraigT](https://community.easymorph.com/u/CraigT)\
**Post date:** [September 12, 2022, 6:01pm UTC](https://community.easymorph.com/t/excel-command-vba-not-working/3894/5 "2022-09-12T18:01:02Z")

</div>

Don't know if this is relevant, but have you previously opened this Excel file directly on the system that Server is running on? Looking at the Excel file security angle.

Normally when you open an xlsm file for the first time as a specific user, you are met with the old "contains macros, allow or deny" message/notification. If this hasn't been done and cleared (accepted), maybe it's hung there? Open the file directly, clear/accept macros, save and close. Then try again?

Latest "security" is for files that were retrieved from an external/web location (or _perceived_ to be external), Excel will "lock it down" until you "unblock" it. In File Explorer, find the file. Right-click and select Properties. Look for an "Unblock file" checkbox at the bottom-right corner of the "General" tab. If there, check it and hit OK. If not there, you're good.

CraigT

---

<div class="post-metadata">

**Author:** ![ruud.vanmiddendorp](https://community.easymorph.com/letter_avatar_proxy/v4/letter/r/b9bd4f/32.png) [@ruud.vanmiddendorp](https://community.easymorph.com/u/ruud.vanmiddendorp)\
**Post date:** [September 14, 2022, 8:09am UTC](https://community.easymorph.com/t/excel-command-vba-not-working/3894/6 "2022-09-14T08:09:26Z")

</div>

Thanks for the suggestions.

- I will try first to create a EasyMorph account on the server (instead of using Administrator and/or Local Service) and give that account al the needed rights.
- If that does not solve the problem we will try the suggestions from Craig.

Thanks, Ruud

---

<div class="post-metadata">

**Author:** ![ruud.vanmiddendorp](https://community.easymorph.com/letter_avatar_proxy/v4/letter/r/b9bd4f/32.png) [@ruud.vanmiddendorp](https://community.easymorph.com/u/ruud.vanmiddendorp)\
**Post date:** [October 5, 2022, 9:20am UTC](https://community.easymorph.com/t/excel-command-vba-not-working/3894/7 "2022-10-05T09:20:37Z")

</div>

Just an update:

I've followed all suggestions and also the new article from Dmitry gave a lot more insight ([If you have problems running Excel Command on Server](https://community.easymorph.com/t/if-you-have-problems-running-excel-command-on-server/3920)).

But unfortunately I was not able to solve the issue (same issue remains). I'm giving up since the functionality to use Excel macros is not really a must have and to invest more time in the issue is not worth it for us.

The issue seems to be related to the VM, Windows account and/or Excel. I don't think it's a EasyMorph issue.

Regards, Ruud
