Open Excel Book

dantb

Active Member
Joined
Mar 20, 2002
Messages
358
Hi all. I am trying to open a excel workbook with a cdm button. The workbook is named Exlabor.xls,and dont know if it maters but is in a subdirectory of the workbook with the cmd. This is what I have do I nead any thing else with it ?

Private Sub CdmElabor_Click()
Workbooks.Open Filename:="exlabor.xls"
Sheets("sheet1").Select
End Sub
 
I know what your trying to do that is what I am also trying to do create a univeral workbook that works no matter where its put you can refer to a variable as the workbook name and directory that makes the macro run slower but other wise does anyone have any code for this that picks up the workbooks current location??
 
Upvote 0

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
On 2002-04-02 20:30, brettvba wrote:
I know what your trying to do that is what I am also trying to do create a univeral workbook that works no matter where its put you can refer to a variable as the workbook name and directory that makes the macro run slower but other wise does anyone have any code for this that picks up the workbooks current location??

Try this mod to J walkenbacks formula

Function GetDirPath_ThisWorkbook() As String
'Returns the path from a filespec
Dim x As Variant
x = Split(ThisWorkbook.FullName, Application.PathSeparator)
ReDim Preserve x(0 To UBound(x) - 1)
GetDir_ThisWorkbook = Join(x, Application.PathSeparator) & Application.PathSeparator
End Function

HTH
 
Upvote 0
Does the following not work?

Code:
Dim x As Variant
x = ThisWorkbook.Path & ""

Where the double backslash is really only one.

Cheers, Nate
This message was edited by NateO on 2002-04-03 07:36
 
Upvote 0

Forum statistics

Threads
1,213,520
Messages
6,114,099
Members
448,548
Latest member
harryls

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