Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default FTP Accessing remote files where filenames are unknown

Hi Al

I worked out a way to do this that was just fine ... then my host decided to implement passive ftp transfers and so now it doesn't work :( ... Previously I opened a dummy file whose name I knew using ..

Workbooks.OpenText (ftpURL + ftpRootDirectory + "dummy.txt"
Close '[ not sure that this is necessary ... but what the heck
Workbooks("dummy.txt").Close (False

... this got me a password dialogue box (which is good in this application) .. and then I accessed the list of files with ..

With ActiveSheet.QueryTables.Add(Connection:=
"TEXT;" + ftpURL + ftpRootDirectory, Destination:=Range("A1")
.FieldNames = Fals
.RowNumbers = Fals
.FillAdjacentFormulas = Fals
.PreserveFormatting = Fals
.RefreshOnFileOpen = Fals
.RefreshStyle = xlInsertDeleteCell
.SavePassword = Fals
.SaveData = Tru
.AdjustColumnWidth = Fals
.RefreshPeriod =
.TextFilePromptOnRefresh = Fals
.TextFilePlatform = 125
.TextFileStartRow =
.TextFileParseType = xlDelimite
.TextFileTextQualifier = xlTextQualifierNon
.TextFileConsecutiveDelimiter = Fals
.TextFileTabDelimiter = Tru
.TextFileSemicolonDelimiter = Fals
.TextFileCommaDelimiter = Fals
.TextFileSpaceDelimiter = Fals
.TextFileColumnDataTypes = Array(xlTextFormat
.TextFileTrailingMinusNumbers = Fals
.Refresh BackgroundQuery:=Fals
End Wit

... which put the list in an emptied worksheet from where I could parse the list and open each file of interest explicitly using the same method

Now that passive ftp is required Excel hangs (of course) on the ...

Workbooks.OpenText (ftpURL + ftpRootDirectory + "dummy.txt"

All help appreciated, thank

Gly



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,236
Default FTP Accessing remote files where filenames are unknown

Suggest you Shell out to an external program to retrieve the files you're
after.

I know of one quite good program for pulling data from ftp/web sites: wget

--
Rob van Gelder - http://www.vangelder.co.nz/excel


"GeeBee" wrote in message
...
Hi All

I worked out a way to do this that was just fine ... then my host decided

to implement passive ftp transfers and so now it doesn't work :( ...
Previously I opened a dummy file whose name I knew using ...


Workbooks.OpenText (ftpURL + ftpRootDirectory + "dummy.txt")
Close '[ not sure that this is necessary ... but what the heck]
Workbooks("dummy.txt").Close (False)

... this got me a password dialogue box (which is good in this

application) .. and then I accessed the list of files with ...

With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;" + ftpURL + ftpRootDirectory, Destination:=Range("A1"))
.FieldNames = False
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = False
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = False
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 1252
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierNone
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(xlTextFormat)
.TextFileTrailingMinusNumbers = False
.Refresh BackgroundQuery:=False
End With

... which put the list in an emptied worksheet from where I could parse

the list and open each file of interest explicitly using the same method.

Now that passive ftp is required Excel hangs (of course) on the ...

Workbooks.OpenText (ftpURL + ftpRootDirectory + "dummy.txt")

All help appreciated, thanks

Glyn






  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default FTP Accessing remote files where filenames are unknown

Thanks Rob ... was hoping to avoid all that ... but if it must be ... hi ho ... hi ho
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,236
Default FTP Accessing remote files where filenames are unknown

There definately are ways of opening an FTP connection and transferring
files from a macro.


I'm not saying you *must* avoid FTP operations within a macro. I'm just
saying that Shell is what I'd do.
Perhaps the best reason is you can rely on an external program which has
been thoroughly tested (like wget) - that way you don't have to stress and
debug whenever an FTP transfer fails.

--
Rob van Gelder - http://www.vangelder.co.nz/excel


"GeeBee" wrote in message
...
Thanks Rob ... was hoping to avoid all that ... but if it must be ... hi

ho ... hi ho


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 49
Default FTP Accessing remote files where filenames are unknown

Someone posted this for me a couple of days ago - not sure if it will work
or not. Obviously you can adapt the sub to have the user and password as a
variable by having the URL built up from a number of strings - it will end
up in the format or whatever. Otherwise you
can build up a batch file in text but it's a pain, and Excel will not know
when the download is completed.


'API file download call
Private Declare Function URLDownloadToFile Lib "urlmon" Alias _
"URLDownloadToFileA" (ByVal pCaller As Long, ByVal strURL As String, _
ByVal strFileName As String, ByVal dwReserved As Long, _
ByVal lpfnCB As Long) As Long

Public Sub GetInternetFile(strFileName As String, strTargetFolder As String)
Dim lReturn As Long
Dim strFullURL As String
Dim strLocation As String

strFullURL = "http://100.100.100.100/" & strFileName
strLocation = strTargetFolder & strFileName

On Error Resume Next
SetAttr strLocation, vbNormal
On Error GoTo 0

lReturn = URLDownloadToFile(0, strFullURL, strLocation, 0, 0)
If lReturn < 0 Then MsgBox "download failed"
End Sub


Cheers,
Jeff

"GeeBee" wrote in message
...
Hi All

I worked out a way to do this that was just fine ... then my host decided

to implement passive ftp transfers and so now it doesn't work :( ...
Previously I opened a dummy file whose name I knew using ...


Workbooks.OpenText (ftpURL + ftpRootDirectory + "dummy.txt")
Close '[ not sure that this is necessary ... but what the heck]
Workbooks("dummy.txt").Close (False)

... this got me a password dialogue box (which is good in this

application) .. and then I accessed the list of files with ...

With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;" + ftpURL + ftpRootDirectory, Destination:=Range("A1"))
.FieldNames = False
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = False
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = False
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 1252
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierNone
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(xlTextFormat)
.TextFileTrailingMinusNumbers = False
.Refresh BackgroundQuery:=False
End With

... which put the list in an emptied worksheet from where I could parse

the list and open each file of interest explicitly using the same method.

Now that passive ftp is required Excel hangs (of course) on the ...

Workbooks.OpenText (ftpURL + ftpRootDirectory + "dummy.txt")

All help appreciated, thanks

Glyn






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
excel files in my docs have numbered filenames and are duplicates sss Setting up and Configuration of Excel 1 December 11th 07 11:37 PM
Accessing cells in other files [email protected] Excel Discussion (Misc queries) 4 October 5th 06 02:32 PM
using wildcard characters for filenames in externally linked files Harold Good Excel Discussion (Misc queries) 0 June 27th 06 03:40 AM
why are the help files now remote? Sean Excel Discussion (Misc queries) 2 April 1st 06 10:11 PM
Acquiring filenames for multiple files with GetOpenFilename John Excel Programming 1 December 17th 03 06:51 AM


All times are GMT +1. The time now is 02:12 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"