0

In Excel VBA I write: Set mWB = Application.Workbooks("File.xlsx")

Then: mWB.Close() I noticed is a possibility, but in the autocomplete list I only see close, not open.

How can I open an excel file in VBA using a variable of type Excel (Dim mWB As Workbook) that holds a reference to the file?

I don't want to use: Application.Workbooks.Open ("File.xlsx"), which I know is possible!

2 Answers 2

1

Simple answer is that isn't how that class works. If you wanted to though, you could create a class to do that?

Sign up to request clarification or add additional context in comments.

1 Comment

Workbook objects store references to workbooks that are in memory. If the workbook is closed, it cannot be referenced as a workbook.
0

Try

set mwb = Application.Workbooks.Open ("File.xlsx") 

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.