VBA - open an excel workbook

maxon

New Member
Joined
Oct 28, 2015
Messages
43
Hi All,

I have probably easy question, but I stucked on it.

I would like to open the workbook like this:

Code:
Dim myfile as string

myfile = Workbooks.Open(ThisWorkbook.Path & "\File.xls")

myfile.open
etc.

What im doing wrong?
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Try:
Dim myfile As Workbook
Set myfile = Workbooks.Open("Path to your workbook\Workbooks name.xls")
 
Last edited:
Upvote 0
I cannot do this this way when I would like to use Thisworkbook.path, there is an error.

Dim EXCEPTIONGENERAL As Workbook
set EXCEPTIONGENERAL Workbooks.Open(ThisWorkbook.Path & "\myFile.xls")
 
Upvote 0
Check post #2 and #4 again.

I guess your workbooks name is: myfile.xls
Only you know the exact path to your workbook you want to open.
Here is an example of a workbook path to a file on your harddrive C:
("C:\Users\maxon\Documents\excelstuff\myfile.xls")
Right click the file in Windows Explorer, choose properties and there you can see the path.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,184
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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