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

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Just open the file in the same instance of Excel:

Code:
Workbooks.Open "c:\25C2-W44-1.xlsm"
 
Upvote 0
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,214,927
Messages
6,122,311
Members
449,080
Latest member
jmsotelo

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