View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Ludo Ludo is offline
external usenet poster
 
Posts: 74
Default Force to Directory

Hi,

I'm trying to write some code to force the current directory to an
other one, where my data files reside.

I have following code

In a module i have :
Public Const sFMTLogFile = "D:\Files\FMTLogFiles\"
Public Const sFMTPrefix = "FmtLog_Snr"

In another module i gave:

Sub OpenOneFile()
Dim fn As Variant
Dim OldDir As String

OldDir = ThisWorkbook.path
ChDir sFMTLogFile
fn = Application.GetOpenFilename("Text-files,*.txt", _
1, "Select One File To Open", , False)
If TypeName(fn) = "Boolean" Then Exit Sub
Workbooks.Open fn
End Sub

I was hoping that the ChDir would change the dir to the one preset in
the constant sFMTLogFile so that with the GetOpenFilename, the form
point to the desired directory, witch ist'n the case.

What goes wrong?

any help welcome

ludo