Open an excel file and automatically attach a specific sheet to it from another file.

tvagge

New Member
Joined
Nov 16, 2016
Messages
34
Hi guys,

This is maybe a little bit extreme and off-topic (!)....
Is there a way when I open an excel file named "db*****" (e.g db12525, db25658, db98745, etc), a specific sheet (named "calc" from another file named calculate.xls) to be attached to the opened file automatically ?
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
In Workbook's module (ThisWorkbook):
Code:
Private Sub Workbook_Open()
    Dim wkbCalc As Workbook
    Set wkbCalc = Workbooks.Open("FULL_PATH_TO_CALC_WORKBOOK")
    wkbCalc.Sheets("calc").Copy ThisWorkbook.Sheets(1)
    wkbCalc.Close False
End Sub
 
Upvote 0
Wow! That was fast!

I didn't get it to work...
Let me explain again:
I have multiple files named like "db*****". These files are created by a database, with different file name everytime.
I want everytime I open these kind of files (and trust me, these files are many...), a specific sheet named "calc" from a specific xlsm file named "calculate.xlsm" to be attached to the file I open automatically.
E.g:
When I open the file named "db12345.xls", the sheet "calc" automatically to be attached to it.
When I open the file named "db12222.xls", the sheet "calc" automatically to be attached to it.
When I open the file named "db13212.xls", the sheet "calc" automatically to be attached to it.

etc...
 
Upvote 0
I see. You won't be able to this manually because macros must exists in those db*** workbooks.
To make it happen, you must programmatically (i.e. from macros in root workbook) open those db** files.
 
Upvote 0

Forum statistics

Threads
1,213,543
Messages
6,114,245
Members
448,555
Latest member
RobertJones1986

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