![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: Mar 2002
Location: Arkansas
Posts: 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 |
|
|
|
|
|
#2 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Christchurch New Zealand
Posts: 1,030
|
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 ] |
|
|
|
|
|
#3 |
|
Board Regular
Join Date: Mar 2002
Location: Arkansas
Posts: 358
|
Ok will try Brett thx. If in the same directory code is fine, but in different Im having trouble. Thanks again Dan
|
|
|
|
|
|
#4 | |
|
MrExcel MVP
Join Date: Feb 2002
Location: Auckland, New Zealand
Posts: 4,209
|
Quote:
Just put the the full file path and file name in your open call routine |
|
|
|
|
|
|
#5 |
|
Board Regular
Join Date: Mar 2002
Location: Arkansas
Posts: 358
|
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 |
|
|
|
|
|
#6 |
|
Legend
Join Date: Feb 2002
Location: Minneapolis, Mn, USA
Posts: 9,704
|
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.
|
|
|
|
|
|
#7 |
|
Board Regular
Join Date: Mar 2002
Location: Arkansas
Posts: 358
|
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.
|
|
|
|
|
|
#8 |
|
Legend
Join Date: Feb 2002
Location: Minneapolis, Mn, USA
Posts: 9,704
|
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, NateO [ This Message was edited by: NateO on 2002-04-02 19:59 ] |
|
|
|
|
|
#9 |
|
Board Regular
Join Date: Mar 2002
Location: Arkansas
Posts: 358
|
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.
|
|
|
|
|
|
#10 |
|
Legend
Join Date: Feb 2002
Location: Minneapolis, Mn, USA
Posts: 9,704
|
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)
_________________ Cheers, NateO [ This Message was edited by: NateO on 2002-04-02 20:23 ] |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|