PDA

View Full Version : Solved: Hyperlink to folder



HV_L
01-24-2012, 09:13 AM
Hi, I have in column A numbers from 1 -250
I add new rows by userform and then set several formula's and the form data in the new row.
I manually created links from this first row looking like this:

=HYPERLINK("D:\Documents\AV\154";"154")
How can I grab (with VBA) the used numbers in this link and create new link in the new row?
So, in this case the link created should look like

=HYPERLINK("D:\Documents\AV\155";"155")
Code used in the Form:

Private Sub OpslaanButton_Click() 'Make Sheet digid Active Sheets("digid").Activate Dim emptyRow As Long Dim ws As Worksheet Set ws = Worksheets("digid") 'find first empty row in database emptyRow = ws.Cells.Find(What:="*", SearchOrder:=xlRows, _ SearchDirection:=xlPrevious, LookIn:=xlValues).Row + 1 With ws.[a1].CurrentRegion lRow = .Row + .Rows.Count .Cells(lRow, "C").Formula = "=IF(OFFSET(Klnr,ROW()-1,MATCH(""Opm"",Print_Titles,0)-1)<>"""",HYPERLINK(""#"" & CELL(""adres"",OFFSET(Klnr,ROW()-1,MATCH(""Opmerking"",Print_Titles,0)-1)),""bekijk""),"""")" .Cells(lRow, "M").Formula = "=IF(OFFSET(Klnr,ROW()-1,MATCH(""Opm"",Print_Titles,0)-1)<>"""",HYPERLINK(""#"" & CELL(""adres"",OFFSET(Klnr,ROW()-1,MATCH(""Klnr"",Print_Titles,0)-1)),""terug""),"""")" End With 'Export Forminput to worksheet Cells(emptyRow, 4).Value = Txtsofi.Value Cells(emptyRow, 5).Value = TxtVoorl.Value Cells(emptyRow, 6).Value = Txtnaam.Value Cells(emptyRow, 7).Value = Txtadres.Value Cells(emptyRow, 8).Value = Txtnr.Value Cells(emptyRow, 9).Value = TxtPostcode.Value Cells(emptyRow, 10).Value = Txtwoonpl.Value Cells(emptyRow, 11).Value = Txtdigid.Value Cells(emptyRow, 12).Value = Txtdigiww.Value Cells(emptyRow, 14).Value = TxtOpm.Value End Sub

frank_m
01-24-2012, 11:10 AM
You will need to tidy up that last part, before anyone is likely to want to look it over..
As it is now, a couple dozen lines of code, are all in one line.

Edit:
In the long run you'll be a lot better off if you understand proper considerations for cross posting.
It's well explained at this link.
http://www.excelguru.ca/content.php?184

Cross posted here
http://www.vbforums.com/showthread.php?p=4122997
and here
http://www.excelforum.com/excel-programming/810964-linking-to-folder.html

HV_L
01-24-2012, 11:46 AM
I previewed the post,then it was not in one line.. and I don't see the edit button..
Crossposting, since I get no answer anywhere I try several forums, is that wrong?

frank_m
01-24-2012, 12:01 PM
Just trying to enlighten, not reprimand.. There is a right and a wrong way to cross post. Part of doing it correctly is to provide links to all the other cross posts. In this way others can see if any progress has been made towards your solution. (Helps protect them from wasting their time on something that may already have been answered)

All the rational is explained well at the link I gave you.

As for the edit button, that disappears after about 15 to 30 minutes.

I'd recommend just adding a new post and explaining that it is a correction for your first post.

The code tags you used are not the easiest to read.. If you highlight all the text that is code, then click the green colored VBA button, that will wrap it with VBA tags for the best readability

Paul_Hossler
01-24-2012, 12:03 PM
Crossposting, since I get no answer anywhere I try several forums, is that wrong?

Not wrong, but it is considered polite to mention the crossposting (with a link) so that potential responders are aware that you might already have an answer so people do not spend time on something that is no longer a problem.

Likewise, it's also considered polite to mark a thread as "Solved" (under Thread Tools above the first post) when you get a question answered. (for future reference)

Paiul

HV_L
01-24-2012, 12:27 PM
Just putting my number of posts to 5, so I can insert LINKS!