Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

InternetExplorer.Application - dynamic ahref problem

Status
Not open for further replies.

lauraSatellite

Technical User
Jul 22, 2004
35
IE
Hi,
I have the following .vbs file:

'=====================Get Current Folder Location
Set sh = CreateObject("WScript.Shell")
currentLocation = sh.CurrentDirectory

Set objExplorer = WScript.CreateObject("InternetExplorer.Application")
DisplayInterface
'=====================Internet Explorer Window
Sub DisplayInterface()
objExplorer.Navigate "about:blank"
objExplorer.ToolBar = 0
objExplorer.StatusBar = 1
objExplorer.Width=800
objExplorer.Height = 550
objExplorer.Left = 0
objExplorer.Top = 0
Do While (objExplorer.Busy)
Wscript.Sleep 200
Loop
objExplorer.Visible = 1
objExplorer.Document.Body.InnerHTML = FunctionGetFolders(currentLocation)
End Sub
'=====================Retrieve List of Folders in folderspec
Function FunctionGetFolders(folderspec)
Dim fs, f, f1, s, sf
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(folderspec)
Set sf = f.SubFolders
For Each f1 in sf
s = s & f1.name & "<P>"
Next
FunctionGetFolders = s
End Function

This results in the folders in folderspec being listed on the html page.
I want to turn the items in this list into <a href>'s to the named folder. It sounds simple but i am having difficulty with it. If anyone knows what syntax i should be using please let me know.
i googled this but was unable to come up with an appropriate answer with what i found.
Any help would be greatly appreciated.
 
Replace this with something like this:
s = s & "<a href='" & f1.path & "'>" & f1.name & "</a><P>"


Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Thanks for your reply PHV, this did help, although the links cannot be followed. When i click a link, there seems to be no effort made to open the target folder.

I do need a folder to be opened, however I tried specifying a file, rather than a folder, just to check if this was the problem, but the link to a file wouldnt open either.

When i hover over the link, the toolbar displays the following information:
file:///C:/TheCorrectFolder
I added a / to the end of the target to give:
file:///C:/TheCorrectFolder/ just incase this made some difference, but it didnt. Backslash didnt work either.

Any ideas on why this link wont open a folder or a file?
 
lauraSatellite,

First, you've to write up an full-fleged html document to the window. Second, You have to furnish behavior for the anchor on folder.

The minimal modification would be something like this.
Code:
'...above the same
'objExplorer.Document.Body.InnerHTML = FunctionGetFolders(currentLocation)    'commented out
objExplorer.Document.write linked_FunctionGetFolders(currentLocation)

Function linked_FunctionGetFolders(folderspec) 
    Dim fs, f, f1, s, sf 
    Set fs = CreateObject("Scripting.FileSystemObject") 
    Set f = fs.GetFolder(folderspec) 
    Set sf = f.SubFolders 
    s="<html><body>"
    For Each f1 in sf 
        s=s & "<a style='behavior: url(""#default#AnchorClick"");'" & " target=_blank" & " href='folder:///" & f1.path & "\" & "'" & " folder='" & f1.path & "'>" & f1.name & "</a><P>"
    Next
    s=s & "</body></html>"
    linked_FunctionGetFolders = s
End Function
regards - tsuji
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top