[VBA] RE GetOpenFileName, I want to point Excel to a file, and then reference that in other modules

RockandGrohl

Well-known Member
Joined
Aug 1, 2018
Messages
810
Office Version
  1. 365
Platform
  1. Windows
Hi all,

Doing a new sheet for reporting, I want to report on a campaign. Let's say our campaign is called "70. London"

I use GetOpenFilename to point Excel to this, and then reference that file as 'facml'

So now when I talk about facml in that module, it knows the file name and location, so if I need to open it, I can just write "facml.open" false (for read only)

That's all well and good in that module, but what about in other modules?

Let's say I have another module that needs to open facml and grab some information from it, will I have to do the "get open filename" process again, or can I just point it to my existing facml that I already defined in the other module?

A potential workaround I'm seeing is to write the path and filename string for facml in a cell that's out of sight, and then say facml = cell, to then open that filename.

Thanks.
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
You can declare facml outside any function and sub and with the PUBLIC keyword. That makes facml a global variable, which can be used by all modules and, thus, could be hard to track in a big project.
Code:
Public facml As Workbook

An alternative is to pass it by reference.
 
Upvote 0

Forum statistics

Threads
1,224,819
Messages
6,181,153
Members
453,021
Latest member
Justyna P

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