Getopenfilename Default File Path For My Computer

 admin  

GetOpenFileName on Vista, won't recognise lpstrInitialDir. Thread starter JohnD; Start date Sep 3, 2007; J. Sep 3, 2007 #1. My Computer System One. Mar 26, 2008 #3 The problem is that in XP the 'lpstrInitialDir' can take a file path and it is smart enough to realise that you are refering to the directory that contains this file. Getopenfilename Default File Pathway In Word VBA Excel Getting File Path (ends with folder)From a previous question I know how to go about letting the user click on a. In the same batch were created through the identical pathway and did.

My computer file path

My Computer File Path

Getopenfilename Default File Path For My Computer

File Path For Excel

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:
[vba]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
[/vba]
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.
If anyone could shed some light on this, it would be appreciated!
   Coments are closed