Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I want to be able to force a browser window to look in a particular polder,
whenever I wish to import data. I have tried ChDir and path commands, but am a bit stuck. Can anybody please help? |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
you don't explain why you think that it doesn't work...
Sub testfolder() Dim fn As String ChDrive "H" ChDir "H:\Excel_Demos\" fn = Application.GetOpenFilename("EXCEL(*.xls),*.xls") End Sub if the directory doesn't exist the function will raise an error - you will therefore need to add an error handler "tcbootneck" wrote: I want to be able to force a browser window to look in a particular polder, whenever I wish to import data. I have tried ChDir and path commands, but am a bit stuck. Can anybody please help? |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks.
Maybe I should have given some more info. I want to import a text file that is on a network drive and therefore wish to use a path name as opposed to a dir name i.e \\network\folder\ and list ..txt files. I have managed to force it to look for .txt files only, it's just the need to point it at the right folder where the .txt files are situated. Example of the code within X's XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX Dim data_dir As String data_dir = "\\folder\nationals\Ad_Hoc_Project_Live\Data\" Set fs = Application.FileSearch With fs .LookIn = "data_dir" .Filename = "*.txt*" End With Title = "Select the file to import" strFileLoc = Application.GetOpenFilename("Text Files (*.txt), *.txt") XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX strFileLoc is publicly declared Thanks again "tcbootneck" wrote: I want to be able to force a browser window to look in a particular polder, whenever I wish to import data. I have tried ChDir and path commands, but am a bit stuck. Can anybody please help? |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi tcbootneck
You can use this Private Declare Function SetCurrentDirectoryA Lib _ "kernel32" (ByVal lpPathName As String) As Long Public Sub ChDirNet(szPath As String) ' Rob Bovey Dim lReturn As Long lReturn = SetCurrentDirectoryA(szPath) If lReturn = 0 Then Err.Raise vbObjectError + 1, "Error setting path." End Sub See how I use it here http://www.rondebruin.nl/copy3.htm#select -- Regards Ron de Bruin http://www.rondebruin.nl "tcbootneck" wrote in message ... I want to be able to force a browser window to look in a particular polder, whenever I wish to import data. I have tried ChDir and path commands, but am a bit stuck. Can anybody please help? |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
See Example 6 on this page
http://www.rondebruin.nl/copy3.htm#select -- Regards Ron de Bruin http://www.rondebruin.nl "Ron de Bruin" wrote in message ... Hi tcbootneck You can use this Private Declare Function SetCurrentDirectoryA Lib _ "kernel32" (ByVal lpPathName As String) As Long Public Sub ChDirNet(szPath As String) ' Rob Bovey Dim lReturn As Long lReturn = SetCurrentDirectoryA(szPath) If lReturn = 0 Then Err.Raise vbObjectError + 1, "Error setting path." End Sub See how I use it here http://www.rondebruin.nl/copy3.htm#select -- Regards Ron de Bruin http://www.rondebruin.nl "tcbootneck" wrote in message ... I want to be able to force a browser window to look in a particular polder, whenever I wish to import data. I have tried ChDir and path commands, but am a bit stuck. Can anybody please help? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
file browser window | Excel Discussion (Misc queries) | |||
open browser window at my given location | Excel Programming | |||
Opening browser window | Excel Programming | |||
Running macro in a browser window | Excel Programming | |||
Close Browser window with VBA | Excel Programming |