Opening excel file with VB issue

allen11584

New Member
Joined
Nov 9, 2011
Messages
3
Hello,

Please bare with me, I am just learning VB. I have macros in my personal.xlsb file so that they can be accessed from different excel files. I am using the following code to open an excel file:

Dim objExcel As Object
Set objExcel = CreateObject("Excel.application")
objExcel.Visible = True 'if you want to see excel during the program
objExcel.Workbooks.open "c:\25C2-W44-1.xlsm"

The code opens my file (25C2-W44-1.xlsm), but personal.xlsb cannot be accessed. I need to mention that I am opening the above code from another excel file using a command button.

Is there a way to open my file using VB code, but still be able to use the macros from personal.xlsb?

Thank you
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop

shg

MrExcel MVP
Joined
May 7, 2008
Messages
21,836
Office Version
  1. 2010
Platform
  1. Windows
Just open the file in the same instance of Excel:

Code:
Workbooks.Open "c:\25C2-W44-1.xlsm"
 
Upvote 0

allen11584

New Member
Joined
Nov 9, 2011
Messages
3
Ok, one more quick question. In the code you gave me it works to open the current file, but what if the file name in that folder changed weekly. An example of this would be:

25C2-W44.xlsm - Week 44
25C2-W45.xlsm - Week 45

Is there a way to code so it sees the last two numbers change?
 
Upvote 0

Forum statistics

Threads
1,195,748
Messages
6,011,429
Members
441,614
Latest member
TiaGtz

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