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
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
try

ChDir "W:Directory"

Workbooks.Open filename:="W:BuyersManFilesexlabor.xls"

there is only one backslash though don't know why it puts in 2
where w: is the drive
This message was edited by brettvba on 2002-04-02 18:56
This message was edited by brettvba on 2002-04-02 18:57
This message was edited by brettvba on 2002-04-02 18:58
 
Upvote 0
Ok will try Brett thx. If in the same directory code is fine, but in different Im having trouble. Thanks again Dan
 
Upvote 0
On 2002-04-02 19:00, dantb wrote:
Ok will try Brett thx. If in the same directory code is fine, but in different Im having trouble. Thanks again Dan

As well as what Brett suggested....
Just put the the full file path and file name
in your open call routine
 
Upvote 0
Thanks Again for your Help It works Great. In case these files are put into anouther directory Like C:/Program Files/ (or what ever the user Picks), is there anyway of leaving the Whole path out ? This is what I have.

Private Sub CdmElabor_Click()
FrmLbedit.Hide
ChDir "C:Unit PriceDocuments"
Workbooks.Open Filename:="C:Unit PriceDocumentsexlabor.xls"
Sheets("sheet1").Select
End Sub
 
Upvote 0
If you find a way to store what the user picks, whether it's a cell entry or an input box. It may behoove you to elaborate as to how the user chooses their target directory.
 
Upvote 0
not a cell or pick. When someone Actualy installs the program, they have a choice of my default directory or choising there own. And if they choise there own, I dont think the code will work.
 
Upvote 0
Depends how they choose their's, if it's a global variable, you may be able to refer to it in your code. Do they choose via Excel or Windows (e.g., Add/Remove Programs)?

_________________
Cheers,<font size=+2><font color="red"> Nate<font color="blue">O</font></font></font>
This message was edited by NateO on 2002-04-02 19:59
 
Upvote 0
I have a simple installer program, I have no dll's, or special system files, just a directory with 6 sub directories. Just trying to make it easy to install with out using copy/Paste.
 
Upvote 0
I have to apologize, I still don't know contextually as to how I best answer. You could do a file search on a drive, but multiples could prove to be a challenge. You could also have the user browse for the file using:

Code:
Dim myFl As Variant
myFl = Application.GetOpenFilename("Excel-files,*.xls", 1, "Select Yer File", , False)

myFl will hold the filepath & filename (i.e., Workbooks.Open filename:=myFl)


_________________
Cheers,<font size=+2><font color="red"> Nate<font color="blue">O</font></font></font>
This message was edited by NateO on 2002-04-02 20:23
 
Upvote 0

Forum statistics

Threads
1,213,484
Messages
6,113,923
Members
448,533
Latest member
thietbibeboiwasaco

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