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: 37
Default How to change directory

Folks,

VBA newbie here...I am unable to "change directory" to a folder name that (I
think) is (already) being returned to me via the Sub (I think I need a
function in order to do this but not sure).

The code is below. The main program right below calls out 2 subs and 1
function. What I need to do is chdir to a folder that is returned to me by
the Sub GetMentDesContPath. Do I need to change the Sub to Function in order
to accomplish this?

The program errors out at ChDir MentorDirectory

Thanks,
Varun




Private Sub CommandMAINBUTTON_Click()

Call GetMentDesContPath
MentorDirectory = MentDesContPath

'Check to see if GEOMS ASCII and error out if it does not geoms_ascii
'Check to see if design container has /pcb subdir

If PathExists(MentDesCont & "pcb") = False Then
MsgBox "Invalid Mentor Design container specified, exiting"
Exit Sub
Else
ChDir MentorDirectory

If FileExists(MentDesCont, geoms_ascii) = False Then
MsgBox "Couldn't find geoms_ascii file, exiting"
Exit Sub
Else
'open geoms_ascii file

End If

End If

End Sub


Sub GetMentDesContPath()
With Application.FileDialog(msoFileDialogFolderPicker)
.InitialFileName = "My Computer"
.Title = "Please navigate to the Mentor Design Container"
.Show
If .SelectedItems.Count < 0 Then
MentDesCont = .SelectedItems(1)
End If
End With
End Sub



Function PathExists(pname) As Boolean
' returns true if the path exists
On Error Resume Next
PathExists = (GetAttr(pname) And vbDirectory) = vbDirectory
End Function



Function FileExists(path, fname) As Boolean
With Application.FileSearch
.NewSearch
.Filename = fname
.LookIn = MentDesCont
.Execute
If .FoundFiles.Count = 1 Then
FileExists = True
Else
FileExists = False
End If
End With
End Function

 
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
Change Directory Compass Rose Excel Programming 1 July 30th 07 03:35 PM
Change current directory to the directory that the workbook loads from! alondon Excel Programming 5 April 17th 07 06:05 AM
Change directory Jeff Excel Discussion (Misc queries) 6 September 27th 06 04:08 PM
Change Directory Help! smonczka Excel Programming 3 August 19th 05 05:55 PM
Change directory for DOS window Garry[_4_] Excel Programming 1 January 9th 04 05:44 PM


All times are GMT +1. The time now is 09:58 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"