Opening a file.

Kayslover

Board Regular
Joined
Sep 22, 2020
Messages
153
Office Version
  1. 2013
Platform
  1. Windows
Hi All,

I have a macro that runs on an Open Template and uses the following to set the folder name:-

VBA Code:
Dim ws As Worksheet
Dim fPath As String
fPath = ThisWorkbook.Path & "\"
Dim FolderName As String
FolderName = ThisWorkbook.Path & "\"

Macro get input, creates workbooks and then closes the last open workbook.

I then use the command:-

VBA Code:
Workbooks.Open FileName:="&FolderName" & "01 January.xlsm".

To Open 01 January.xlsm, but the file does not open.

Stepping through the code using F8, closes the last active workbook, and no more code is executed.

Any suggestions?
 

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.

Logit

Well-known Member
Joined
Aug 31, 2016
Messages
4,013
To begin with ... replace : FileName:="&FolderName"

with ... Workbooks.Open FolderName & "01 January.xlsm"
 
Solution

Kayslover

Board Regular
Joined
Sep 22, 2020
Messages
153
Office Version
  1. 2013
Platform
  1. Windows
Logit,

Thanks very much, it worked a treat.
 

Watch MrExcel Video

Forum statistics

Threads
1,130,021
Messages
5,639,583
Members
417,100
Latest member
Simon123456789

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
Top