473,473 Members | 1,893 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Loop through Folders with Hyperlinks

7 New Member
{NB: this is a moderated redirect from this thread: Inserting Hyperlink into a table}


I can get the code line below working by substituting my own strings but I need to loop through a folder of files writing the hyperlink for each file to the table and so need to use variables instead if strings. The code below does not interpret the variable names, presumably because the whole statement is between quotes.

Expand|Select|Wrap|Line Numbers
  1. MySQL = "Update tblTest Set tblTest.[MyHyperlink] = 'Yahoo Home Page#http://www.yahoo.com'"
I have tried a number of things unsuccessfully. How can I substitute the strings for variables so that the hyperlink reflects the current filename?
Aug 27 '18 #1
9 1492
twinnyfo
3,653 Recognized Expert Moderator Specialist
Tegglet,

Welcome to Bytes!

It sounds like your problem is unique to this thread. We would ask you to start a new thread with a new question. You can refer back to this thread if you wish. Also, please flesh out your question a bit and show us what you have tried so far, so that we can better provide guidance to a solution.

If you prefer, I can move your post to begin a new thread. Please let me know.

Thanks!
Aug 27 '18 #2
Tegglet
7 New Member
Yes please do that.
I am about to get my dinner and will respond with more details as requested later this evening.

Many thanks.
Aug 27 '18 #3
twinnyfo
3,653 Recognized Expert Moderator Specialist
Please let me know if this is an appropriate thread title.

Glad I could be of some hepp!
Aug 27 '18 #4
NeoPa
32,556 Recognized Expert Moderator MVP
Here's some template code to handle that sort of thing.

Assuming the Name and the link are in two variables called strName & strLink then the code could include something like :
Expand|Select|Wrap|Line Numbers
  1. strName = "Yahoo Home Page"
  2. strLink = "http://www.yahoo.com"
  3. MySQL = Replace("UPDATE [tblTest] SET [MyHyperlink]='%N#%L'" _
  4.               , "%N", strName)
  5. MySQL = Replace(MySQL, "%L", strLink)
Aug 27 '18 #5
twinnyfo
3,653 Recognized Expert Moderator Specialist
Thanks, NeoPa!

I've been busy at work, haven't had a chance to look much into this.
Aug 27 '18 #6
Tegglet
7 New Member
Hi NeoPa,
Many thanks, that did the trick. Never thought of %var, back to DOS and batch files ;-)
Regards
Ted
I have marked this as "Best Reply". Is that all I need to do to close it?
Aug 28 '18 #7
twinnyfo
3,653 Recognized Expert Moderator Specialist
Tegglet,

That it! Glad we could be of hepp! NeoPa has all sorts of tricks up his sleeve. He taught me that trick recently and it has helped me in constructing my complicated SQL strings.

Hope you have a great day!
Aug 28 '18 #8
NeoPa
32,556 Recognized Expert Moderator MVP
Tegglet:
Never thought of %var, back to DOS and batch files ;-)
Absolutely. In another lifetime I was a bit of a BAT/CMD guru.

If you're interested I have some code I use very heavily to handle multiple replacement vars. It's called MultiReplace() and I find it invaluable. It works with vbBinaryCompare to ensure comparisons are exact.
Expand|Select|Wrap|Line Numbers
  1. 'MultiReplace() takes each pair of parameters from avarArgs() and replaces the
  2. '  first with the second wherever found in strMain.
  3. 'Using VbBinaryCompare means that case is recognised and not ignored.
  4. '08/05/2013 Updated to support passing of an array directly into avarArgs.
  5. Public Function MultiReplace(ByRef strMain As String _
  6.                            , ParamArray avarArgs() As Variant) As String
  7.     Dim intX As Integer
  8.     Dim avarVals() As Variant
  9.  
  10.     'Code to handle avarArgs passed as an existing array.
  11.     If (UBound(avarArgs) = LBound(avarArgs)) _
  12.     And IsArray(avarArgs(LBound(avarArgs))) Then
  13.         ReDim avarVals(LBound(avarArgs) To UBound(avarArgs(LBound(avarArgs))))
  14.         For intX = LBound(avarVals) To UBound(avarVals)
  15.             avarVals(intX) = avarArgs(LBound(avarArgs))(intX)
  16.         Next intX
  17.     Else
  18.         avarVals = avarArgs
  19.     End If
  20.     If (UBound(avarVals) - LBound(avarVals)) Mod 2 = 0 Then Stop
  21.     MultiReplace = strMain
  22.     For intX = LBound(avarVals) To UBound(avarVals) Step 2
  23.         MultiReplace = Replace(Expression:=MultiReplace, _
  24.                                Find:=Nz(avarVals(intX), ""), _
  25.                                Replace:=Nz(avarVals(intX + 1), ""), _
  26.                                Compare:=vbBinaryCompare)
  27.     Next intX
  28. End Function
With that you can simply use :
Expand|Select|Wrap|Line Numbers
  1. strName = "Yahoo Home Page"
  2. strLink = "http://www.yahoo.com"
  3. MySQL = MultiReplace("UPDATE [tblTest] SET [MyHyperlink]='%N#%L'" _
  4.                    , "%N", strName _
  5.                    , "%L", strLink)
Aug 29 '18 #9
Tegglet
7 New Member
Thanks everybody for your help so far.
I am getting in a right pickle with this project so I am starting a new topic describing the core requirements, which are to read the filenames of the contents of a folder into a table and convert the names to hyperlinks. Whatever happened to good old plain and simple get and put?
Aug 29 '18 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: scoop_77 | last post by:
I'm looking for some software that would allow me to point to a folder in Windows Explorer, and have it output an html file with hyperlinks to all of the files within that folder and all of the...
3
by: laura | last post by:
I am writing some code for an intranet and I need to be able to list the files in folders and subfolders and display them in the browser window as with hyperlinks. I've picked up this very...
1
by: Jason Steeves | last post by:
Does anyone know an easy way to get all of the folders and their sub-folders and their sub-folders and so on? I need to get all of the folders and their paths from an inputted parent folder...
6
by: Colleyville Alan | last post by:
I have an application that has an Access table that stores the locations of slides in a Powerpoint file. This used to work fine when there were about 4 files and 200 slides. The database would...
1
by: Darryl Neale | last post by:
I have been tasked with reviving an old database that stopped working about 3 years ago :( On one of the tabs is a list of links to other databases utilising the Hyperlink feature of MS Access...
2
by: Jazzdrums | last post by:
Hello, I've (parts of ) HTML documents and a list of words that I have to transform as an hyperlinks, i.e. surround them with a "<a href="...">" "</a>". A first simple approach is to parse the...
1
by: Vagabond Software | last post by:
I am recursing through ALL folders and sub-folders below a certain level to list all the files of a certain type in those folders. I use two ArrayLists, alFiles and alFolders, to track matching...
4
by: mrmagoo | last post by:
I want to loop through a directory and list all files in hyperlinks. Then when you click on a hyperlink, it opens the file in whatever application it needs. For now I need to do this with Adobe...
1
by: Janna | last post by:
Hello tech savvy gurus! I hope someone can help me! THE PROBLEM: "Cannot open specified file" when I click on a hyperlink in an Access database when it is located on our server. THE...
6
by: veer | last post by:
the programe is about i have one folder named newdata which contain 46 folders and each folder containg multiple mdb files and with in mdb files there are two tables. i want to merge all these...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.