LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default auto open from any folder

I copied and pasted the following code to the "This Workbook" object in
workbook1, and substituted my info where appropriate. I found this in a
previous post by someone else. I wanted a second workbook to automatically
open when I opened the first, because the second workbook contains data lists
that I need for drop-down lists in the first notebook. The first notebook is
an estimating form that, when completed is saved as a new filename everytime
(named for that estimate) in a different folder. The second notebook has the
price lists.

Private Sub Workbook_Open()
'this code will open a second workbook
'with name specified by Const childName
'that is located in the same folder
'with this (parent) workbook.
Const childName = "Holthaus D-L Estimating Guide.xlsx"
Dim ChildIsOpen As Boolean
Dim anyWorkbook As Workbook
For Each anyWorkbook In Workbooks
If anyWorkbook.Name = childName Then
ChildIsOpen = True
Exit For
End If
Next
If Not ChildIsOpen Then
'in case the workbook does not
'exist in this folder
On Error Resume Next ' ignore error
'try to open the child workbook
Workbooks.Open _
Left(ThisWorkbook.FullName, InStrRev(ThisWorkbook.FullName, _
Application.PathSeparator)) & childName
'clear any error that was encountered
If Err < 0 Then
MsgBox childName & " Could not be found/opened"
Err.Clear
End If
'when other book is opened, it becomes the
'active workbook, so come back to this one.
ThisWorkbook.Activate
'reset the error trapping
On Error GoTo 0
End If
End Sub


My problem is that this code tells it to open the file "Holthaus D-L
Estimating Guide.xlsx" located in the same folder. After I save a completed
form as a new name in the completed estimated folder, the file "Holthaus D-L
Estimating Guide.xlsx" is no longer in the same folder as the new file. I
need this code to look for the file "Holthaus D-L Estimating Guide.xlsx" in
any folder.
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
User selection of folder and open all .xls files within folder Barb Reinhardt Excel Programming 4 April 14th 07 01:41 PM
Help: Can open a spreadsheet in a folder which contains spaces in the folder name! 1tsols Excel Programming 17 July 31st 06 04:26 PM
open file from folder save in new folder tim64[_3_] Excel Programming 20 June 17th 05 07:58 PM
I like to open a folder,auto print,save then close tied of opening files Excel Programming 2 April 22nd 05 10:20 PM
Open files in folder - skip if already open Steph[_3_] Excel Programming 6 March 25th 05 06:49 PM


All times are GMT +1. The time now is 01:51 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"