+ Reply to Thread
Results 1 to 5 of 5

Changing Directory for GetOpenFileName

  1. #1
    Chaplain Doug
    Guest

    Changing Directory for GetOpenFileName

    Excel 2003. I am using

    FName = Application.GetOpenFilename("Text Files (*.txt), *.txt", , "Select
    ACH

    to select a file to process. I want this dialog to open into a specific
    folder. Right now it opens into my "My Documents" folder. I have tried:

    Application.DefaultFilePath = "\\hqserver\shared\Finance\Payroll ACH Files"
    and
    Application.DefaultFilePath = "H:\Finance\Payroll ACH Files"

    but neither seems to change the folder the GetOpenFilename looks in. How
    may I accomplish what I am trying to accomplish? Thanks and God bless.
    --
    Dr. Doug Pruiett
    Good News Jail & Prison Ministry
    www.goodnewsjail.org

  2. #2
    Bob Phillips
    Guest

    Re: Changing Directory for GetOpenFileName

    Try ChDir and ChDrive

    --
    HTH

    Bob Phillips

    (remove nothere from email address if mailing direct)

    "Chaplain Doug" <ChaplainDoug@discussions.microsoft.com> wrote in message
    news:4B58420E-A37B-4729-83AC-CDB9D7D5BD01@microsoft.com...
    > Excel 2003. I am using
    >
    > FName = Application.GetOpenFilename("Text Files (*.txt), *.txt", , "Select
    > ACH
    >
    > to select a file to process. I want this dialog to open into a specific
    > folder. Right now it opens into my "My Documents" folder. I have tried:
    >
    > Application.DefaultFilePath = "\\hqserver\shared\Finance\Payroll ACH

    Files"
    > and
    > Application.DefaultFilePath = "H:\Finance\Payroll ACH Files"
    >
    > but neither seems to change the folder the GetOpenFilename looks in. How
    > may I accomplish what I am trying to accomplish? Thanks and God bless.
    > --
    > Dr. Doug Pruiett
    > Good News Jail & Prison Ministry
    > www.goodnewsjail.org




  3. #3
    Ron de Bruin
    Guest

    Re: Changing Directory for GetOpenFileName

    Hi Chaplain

    You must use ChDirNet, copy this at the top of your module

    Private Declare Function SetCurrentDirectoryA Lib _
    "kernel32" (ByVal lpPathName As String) As Long

    Sub ChDirNet(szPath As String)
    Dim lReturn As Long
    lReturn = SetCurrentDirectoryA(szPath)
    If lReturn = 0 Then Err.Raise vbObjectError + 1, "Error setting path."
    End Sub


    Then use this in your macro

    ChDirNet "\\ComputerName\YourFolder"




    --
    Regards Ron de Bruin
    http://www.rondebruin.nl


    "Chaplain Doug" <ChaplainDoug@discussions.microsoft.com> wrote in message news:4B58420E-A37B-4729-83AC-CDB9D7D5BD01@microsoft.com...
    > Excel 2003. I am using
    >
    > FName = Application.GetOpenFilename("Text Files (*.txt), *.txt", , "Select
    > ACH
    >
    > to select a file to process. I want this dialog to open into a specific
    > folder. Right now it opens into my "My Documents" folder. I have tried:
    >
    > Application.DefaultFilePath = "\\hqserver\shared\Finance\Payroll ACH Files"
    > and
    > Application.DefaultFilePath = "H:\Finance\Payroll ACH Files"
    >
    > but neither seems to change the folder the GetOpenFilename looks in. How
    > may I accomplish what I am trying to accomplish? Thanks and God bless.
    > --
    > Dr. Doug Pruiett
    > Good News Jail & Prison Ministry
    > www.goodnewsjail.org




  4. #4
    Chaplain Doug
    Guest

    Re: Changing Directory for GetOpenFileName

    Dear Ron:

    Works like a charm. Thanks. Why did not my approach work?
    --
    Dr. Doug Pruiett
    Good News Jail & Prison Ministry
    www.goodnewsjail.org


    "Ron de Bruin" wrote:

    > Hi Chaplain
    >
    > You must use ChDirNet, copy this at the top of your module
    >
    > Private Declare Function SetCurrentDirectoryA Lib _
    > "kernel32" (ByVal lpPathName As String) As Long
    >
    > Sub ChDirNet(szPath As String)
    > Dim lReturn As Long
    > lReturn = SetCurrentDirectoryA(szPath)
    > If lReturn = 0 Then Err.Raise vbObjectError + 1, "Error setting path."
    > End Sub
    >
    >
    > Then use this in your macro
    >
    > ChDirNet "\\ComputerName\YourFolder"
    >
    >
    >
    >
    > --
    > Regards Ron de Bruin
    > http://www.rondebruin.nl
    >
    >
    > "Chaplain Doug" <ChaplainDoug@discussions.microsoft.com> wrote in message news:4B58420E-A37B-4729-83AC-CDB9D7D5BD01@microsoft.com...
    > > Excel 2003. I am using
    > >
    > > FName = Application.GetOpenFilename("Text Files (*.txt), *.txt", , "Select
    > > ACH
    > >
    > > to select a file to process. I want this dialog to open into a specific
    > > folder. Right now it opens into my "My Documents" folder. I have tried:
    > >
    > > Application.DefaultFilePath = "\\hqserver\shared\Finance\Payroll ACH Files"
    > > and
    > > Application.DefaultFilePath = "H:\Finance\Payroll ACH Files"
    > >
    > > but neither seems to change the folder the GetOpenFilename looks in. How
    > > may I accomplish what I am trying to accomplish? Thanks and God bless.
    > > --
    > > Dr. Doug Pruiett
    > > Good News Jail & Prison Ministry
    > > www.goodnewsjail.org

    >
    >
    >


  5. #5
    Ron de Bruin
    Guest

    Re: Changing Directory for GetOpenFileName

    Hi Chaplain

    MyPath = "C:\Data"
    ChDrive MyPath
    ChDir MyPath

    This is not working if you want to use a network folder
    ChDirNet is working for local and network folders

    But your second example must work if you have used ChDrive and ChDir
    >> > Application.DefaultFilePath = "H:\Finance\Payroll ACH Files"




    --
    Regards Ron de Bruin
    http://www.rondebruin.nl


    "Chaplain Doug" <ChaplainDoug@discussions.microsoft.com> wrote in message news:FC81AC80-E0C4-439F-A311-06B2257AE05A@microsoft.com...
    > Dear Ron:
    >
    > Works like a charm. Thanks. Why did not my approach work?
    > --
    > Dr. Doug Pruiett
    > Good News Jail & Prison Ministry
    > www.goodnewsjail.org
    >
    >
    > "Ron de Bruin" wrote:
    >
    >> Hi Chaplain
    >>
    >> You must use ChDirNet, copy this at the top of your module
    >>
    >> Private Declare Function SetCurrentDirectoryA Lib _
    >> "kernel32" (ByVal lpPathName As String) As Long
    >>
    >> Sub ChDirNet(szPath As String)
    >> Dim lReturn As Long
    >> lReturn = SetCurrentDirectoryA(szPath)
    >> If lReturn = 0 Then Err.Raise vbObjectError + 1, "Error setting path."
    >> End Sub
    >>
    >>
    >> Then use this in your macro
    >>
    >> ChDirNet "\\ComputerName\YourFolder"
    >>
    >>
    >>
    >>
    >> --
    >> Regards Ron de Bruin
    >> http://www.rondebruin.nl
    >>
    >>
    >> "Chaplain Doug" <ChaplainDoug@discussions.microsoft.com> wrote in message
    >> news:4B58420E-A37B-4729-83AC-CDB9D7D5BD01@microsoft.com...
    >> > Excel 2003. I am using
    >> >
    >> > FName = Application.GetOpenFilename("Text Files (*.txt), *.txt", , "Select
    >> > ACH
    >> >
    >> > to select a file to process. I want this dialog to open into a specific
    >> > folder. Right now it opens into my "My Documents" folder. I have tried:
    >> >
    >> > Application.DefaultFilePath = "\\hqserver\shared\Finance\Payroll ACH Files"
    >> > and
    >> > Application.DefaultFilePath = "H:\Finance\Payroll ACH Files"
    >> >
    >> > but neither seems to change the folder the GetOpenFilename looks in. How
    >> > may I accomplish what I am trying to accomplish? Thanks and God bless.
    >> > --
    >> > Dr. Doug Pruiett
    >> > Good News Jail & Prison Ministry
    >> > www.goodnewsjail.org

    >>
    >>
    >>




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1