Ken Puls
01-19-2005, 12:32 PM
Hey guys,
I've just run into an issue with GetOpenFilename, and I can't get past it as of yet...
I'm trying to open the window in a specific directory, but I want to save the path that the user intially has, so that I can reset it there after I'm done. (This file is stored where I don't really want my users fooling around.)
Here's what I've got so far:
Dim InitialPath As String, SourceWBPath as String
'Read the current directory and hold it in memory
InitialPath = CurDir
'Change the directory to where the file should be
ChDir "O:\GL Import"
On Error Resume Next
SourceWBPath = Application.GetOpenFilename("Quickbooks Files (*.IIF),*.IIF")
'Prompt the user to open the file, (limiting the display to QuickBooks files,) and import it
Workbooks.OpenText Filename:= _
SourceWBPath, Origin:=437, StartRow _
:=1, DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, _
ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False, Comma:=False _
, Space:=False, Other:=False, FieldInfo:=Array(Array(1, 2), Array(2, 2), _
Array(3, 2), Array(4, 3), Array(5, 9), Array(6, 2), Array(7, 1), Array(8, 9), Array(9, 2), _
Array(10, 9), Array(11, 9), Array(12, 9), Array(13, 9), Array(14, 9), Array(15, 9))
If Err.Number <> 0 Then
'Means no file was opened
MsgBox "Could not complete procedure!", vbOKOnly
Exit Sub
End If
On Error GoTo 0
'Change the directory back to user's initial directory path
ChDir InitialPath
For some reason, the ChDir command does not seem to be working.... or maybe it is. What I was expecting this to do was to change the path, so that when I hit File|Open (or use GetOpenFilename) it would be in the correct directory.:confused:
If anyone could shed some light on this, it would be appreciated!
I've just run into an issue with GetOpenFilename, and I can't get past it as of yet...
I'm trying to open the window in a specific directory, but I want to save the path that the user intially has, so that I can reset it there after I'm done. (This file is stored where I don't really want my users fooling around.)
Here's what I've got so far:
Dim InitialPath As String, SourceWBPath as String
'Read the current directory and hold it in memory
InitialPath = CurDir
'Change the directory to where the file should be
ChDir "O:\GL Import"
On Error Resume Next
SourceWBPath = Application.GetOpenFilename("Quickbooks Files (*.IIF),*.IIF")
'Prompt the user to open the file, (limiting the display to QuickBooks files,) and import it
Workbooks.OpenText Filename:= _
SourceWBPath, Origin:=437, StartRow _
:=1, DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, _
ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False, Comma:=False _
, Space:=False, Other:=False, FieldInfo:=Array(Array(1, 2), Array(2, 2), _
Array(3, 2), Array(4, 3), Array(5, 9), Array(6, 2), Array(7, 1), Array(8, 9), Array(9, 2), _
Array(10, 9), Array(11, 9), Array(12, 9), Array(13, 9), Array(14, 9), Array(15, 9))
If Err.Number <> 0 Then
'Means no file was opened
MsgBox "Could not complete procedure!", vbOKOnly
Exit Sub
End If
On Error GoTo 0
'Change the directory back to user's initial directory path
ChDir InitialPath
For some reason, the ChDir command does not seem to be working.... or maybe it is. What I was expecting this to do was to change the path, so that when I hit File|Open (or use GetOpenFilename) it would be in the correct directory.:confused:
If anyone could shed some light on this, it would be appreciated!