Make Excel VBA file with FileSystemObject (FSO) "portable"

PeteWright

Active Member
Joined
Dec 20, 2020
Messages
492
Office Version
  1. 365
Platform
  1. Windows
  2. Mobile
Hi there,

I am currently working on an Excel VBA code that uses the Microsoft Scripting Runtime or FileSystemObject (FSO), but I stopped coding for now, because I'm not sure if the File will work on other computers.

To be able to run my VBA code the user needs to press a button on the main sheet which then initiates a lot of other procedures like opening a text file and filling in a sheet with data.
If I am not wrong then:
For this to work (without throwing an error) the corresponding Reference (in this case the Microsoft Scripting Runtime) has to be loaded into the Excel file (via VBA Editor menu Tools > References).

My Excel file will only be used in our company by a few colleagues, so the worst case would be to enable the Runtime on all computers that will run the file.

What I am asking myself now:
How is the runtime implemented?

So my question now is:
What should I do that every user will be able to run my code?

Many thanks in advance.
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
You can assign the variable using late binding so you don't need to add the reference.

VBA Code:
Dim FSO As Object:  Set FSO = CreateObject("Scripting.FileSystemObject")
 
Upvote 0
Solution
You can assign the variable using late binding so you don't need to add the reference.

VBA Code:
Dim FSO As Object:  Set FSO = CreateObject("Scripting.FileSystemObject")
@lrobbo314 Nice, thanks. I'll try it tomorrow at work.

Is there anything else that needs to be done?
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,333
Members
452,636
Latest member
laura12345

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top