![]() |
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 |
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" wrote in message ... 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 |
Changing Directory for GetOpenFileName
Try ChDir and ChDrive
-- HTH Bob Phillips (remove nothere from email address if mailing direct) "Chaplain Doug" wrote in message ... 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 |
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" wrote in message ... 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 |
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" wrote in message ... 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" wrote in message ... 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 |
All times are GMT +1. The time now is 02:16 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com