[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
788
Office Version
  1. 2010
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

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
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,214,642
Messages
6,120,700
Members
448,979
Latest member
DET4492

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