Opening a file.

Kayslover

Board Regular
Joined
Sep 22, 2020
Messages
168
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

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
To begin with ... replace : FileName:="&FolderName"

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

Forum statistics

Threads
1,215,453
Messages
6,124,922
Members
449,195
Latest member
Stevenciu

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