Table

Y

yael

Hi,
Hoe to loop through all the hyperlink in my table? by button click event in
vba
Thank's,
I want to get all this links and save them in my computer at C:\Damo
How can I do this?
I'm new in vba
Yael.
 
G

Gary''s Student

If you have a table of hyperlinks and want to save them to a file then:

Sub Macro1()
With ActiveWorkbook
..SaveAs Filename:="C:\Damo\Book1.htm", FileFormat:=xlHtml
End With
End Sub

This will create an html file with all the links in it. It is also possible
to create single files with a link in each one with VBA.
 
Y

yael

Thank's for your replay,
I have table and hyperlink column type.
I want to get all this links as files and save them in my computer at C:\Damo
for example, if I have myfile.doc, myproject.exe in the hyperlink column, I
want to copy these files into C:\Damo folder and then, if I go to this folder
I'll get by clicking on myfile.doc this document in word
How can I do this?
I have this method:
========================================
Private Sub SaveBtn_Click()
Dim Conn As ADODB.Connection
Dim Rs As ADODB.Recordset
Dim strLink As String
Dim strTemp As String
Set Rs = New ADODB.Recordset
Set Conn = CurrentProject.Connection
Rs.Open "links", Conn, adOpenStatic

Do While Not Rs.EOF
'strTemp = Rs![fname]
strLink = Split(strLink, "#")(0) '??
MsgBox strLink

' copy this file to C:\Damo folder (as file type not only the name)

Rs.MoveNext
Loop

Rs.Close
End Sub
========================================
 
G

Gary''s Student

You may be able to adapt this:

Sub make_links()
'
' Creates hyperlinks in Damo from hyperlinks in cells
'
Sheets("shortcut").Activate
Dim oWSH As Object
Dim oShortcut As Object
Dim sPath As String
For i = 1 To 2
Set oWSH = CreateObject("WScript.Shell")
sPath = "C:\Damo"
Set oShortcut = oWSH.CreateShortCut(sPath & "\" & _
Cells(i, 2).Value & ".lnk")
With oShortcut
.targetpath = Cells(i, 1).Value
.Save
End With
Set oWSH = Nothing
Set oShortcut = Nothing
Next
End Sub


You need a worksheet called "shortcut". Column A contains the hyperlinks.
Column B contains "friendly names" that become file names This routine make
..lnk rather than .url files.

Fix the For loop for as many as you like.
--
Gary''s Student - gsnu200728


yael said:
Thank's for your replay,
I have table and hyperlink column type.
I want to get all this links as files and save them in my computer at C:\Damo
for example, if I have myfile.doc, myproject.exe in the hyperlink column, I
want to copy these files into C:\Damo folder and then, if I go to this folder
I'll get by clicking on myfile.doc this document in word
How can I do this?
I have this method:
========================================
Private Sub SaveBtn_Click()
Dim Conn As ADODB.Connection
Dim Rs As ADODB.Recordset
Dim strLink As String
Dim strTemp As String
Set Rs = New ADODB.Recordset
Set Conn = CurrentProject.Connection
Rs.Open "links", Conn, adOpenStatic

Do While Not Rs.EOF
'strTemp = Rs![fname]
strLink = Split(strLink, "#")(0) '??
MsgBox strLink

' copy this file to C:\Damo folder (as file type not only the name)

Rs.MoveNext
Loop

Rs.Close
End Sub
========================================


Gary''s Student said:
If you have a table of hyperlinks and want to save them to a file then:

Sub Macro1()
With ActiveWorkbook
.SaveAs Filename:="C:\Damo\Book1.htm", FileFormat:=xlHtml
End With
End Sub

This will create an html file with all the links in it. It is also possible
to create single files with a link in each one with VBA.
 
Y

yael

Thank's but I get rt errore about Cells and Sheets.
I need something like this:

============================================
Private Sub SaveBtn_Click()

Dim Conn As ADODB.Connection
Dim Rs As ADODB.Recordset
Dim strLink() As String
Dim strField As String
Dim strFileName() As String
Dim strTemp As String

Set Rs = New ADODB.Recordset
Set Conn = CurrentProject.Connection
Rs.Open "links", Conn, adOpenStatic

Do While Not Rs.EOF
strField = Rs![fname]
strLink = Split(strField, "#")
MsgBox strLink(0)
strFileName = Split(strLink(0), ".")
MsgBox strFileName(0)
' FileCopy strLink, "C:\VbLinks\MyFile2.doc"
Rs.MoveNext
Loop

Rs.Close
End Sub
============================================


Gary''s Student said:
You may be able to adapt this:

Sub make_links()
'
' Creates hyperlinks in Damo from hyperlinks in cells
'
Sheets("shortcut").Activate
Dim oWSH As Object
Dim oShortcut As Object
Dim sPath As String
For i = 1 To 2
Set oWSH = CreateObject("WScript.Shell")
sPath = "C:\Damo"
Set oShortcut = oWSH.CreateShortCut(sPath & "\" & _
Cells(i, 2).Value & ".lnk")
With oShortcut
.targetpath = Cells(i, 1).Value
.Save
End With
Set oWSH = Nothing
Set oShortcut = Nothing
Next
End Sub


You need a worksheet called "shortcut". Column A contains the hyperlinks.
Column B contains "friendly names" that become file names This routine make
.lnk rather than .url files.

Fix the For loop for as many as you like.
--
Gary''s Student - gsnu200728


yael said:
Thank's for your replay,
I have table and hyperlink column type.
I want to get all this links as files and save them in my computer at C:\Damo
for example, if I have myfile.doc, myproject.exe in the hyperlink column, I
want to copy these files into C:\Damo folder and then, if I go to this folder
I'll get by clicking on myfile.doc this document in word
How can I do this?
I have this method:
========================================
Private Sub SaveBtn_Click()
Dim Conn As ADODB.Connection
Dim Rs As ADODB.Recordset
Dim strLink As String
Dim strTemp As String
Set Rs = New ADODB.Recordset
Set Conn = CurrentProject.Connection
Rs.Open "links", Conn, adOpenStatic

Do While Not Rs.EOF
'strTemp = Rs![fname]
strLink = Split(strLink, "#")(0) '??
MsgBox strLink

' copy this file to C:\Damo folder (as file type not only the name)

Rs.MoveNext
Loop

Rs.Close
End Sub
========================================


Gary''s Student said:
If you have a table of hyperlinks and want to save them to a file then:

Sub Macro1()
With ActiveWorkbook
.SaveAs Filename:="C:\Damo\Book1.htm", FileFormat:=xlHtml
End With
End Sub

This will create an html file with all the links in it. It is also possible
to create single files with a link in each one with VBA.
--
Gary''s Student - gsnu200728


:

Hi,
Hoe to loop through all the hyperlink in my table? by button click event in
vba
Thank's,
I want to get all this links and save them in my computer at C:\Damo
How can I do this?
I'm new in vba
Yael.
 
G

Gary''s Student

I understand the problem. My code is designed for an Excel spreadsheet. You
probably want an Access solution. If no one helps you from this posting,
re-post in:

http://www.microsoft.com/office/com...oft.public.access.modulesdaovba&lang=en&cr=US


--
Gary''s Student - gsnu200728


yael said:
Thank's but I get rt errore about Cells and Sheets.
I need something like this:

============================================
Private Sub SaveBtn_Click()

Dim Conn As ADODB.Connection
Dim Rs As ADODB.Recordset
Dim strLink() As String
Dim strField As String
Dim strFileName() As String
Dim strTemp As String

Set Rs = New ADODB.Recordset
Set Conn = CurrentProject.Connection
Rs.Open "links", Conn, adOpenStatic

Do While Not Rs.EOF
strField = Rs![fname]
strLink = Split(strField, "#")
MsgBox strLink(0)
strFileName = Split(strLink(0), ".")
MsgBox strFileName(0)
' FileCopy strLink, "C:\VbLinks\MyFile2.doc"
Rs.MoveNext
Loop

Rs.Close
End Sub
============================================


Gary''s Student said:
You may be able to adapt this:

Sub make_links()
'
' Creates hyperlinks in Damo from hyperlinks in cells
'
Sheets("shortcut").Activate
Dim oWSH As Object
Dim oShortcut As Object
Dim sPath As String
For i = 1 To 2
Set oWSH = CreateObject("WScript.Shell")
sPath = "C:\Damo"
Set oShortcut = oWSH.CreateShortCut(sPath & "\" & _
Cells(i, 2).Value & ".lnk")
With oShortcut
.targetpath = Cells(i, 1).Value
.Save
End With
Set oWSH = Nothing
Set oShortcut = Nothing
Next
End Sub


You need a worksheet called "shortcut". Column A contains the hyperlinks.
Column B contains "friendly names" that become file names This routine make
.lnk rather than .url files.

Fix the For loop for as many as you like.
--
Gary''s Student - gsnu200728


yael said:
Thank's for your replay,
I have table and hyperlink column type.
I want to get all this links as files and save them in my computer at C:\Damo
for example, if I have myfile.doc, myproject.exe in the hyperlink column, I
want to copy these files into C:\Damo folder and then, if I go to this folder
I'll get by clicking on myfile.doc this document in word
How can I do this?
I have this method:
========================================
Private Sub SaveBtn_Click()
Dim Conn As ADODB.Connection
Dim Rs As ADODB.Recordset
Dim strLink As String
Dim strTemp As String
Set Rs = New ADODB.Recordset
Set Conn = CurrentProject.Connection
Rs.Open "links", Conn, adOpenStatic

Do While Not Rs.EOF
'strTemp = Rs![fname]
strLink = Split(strLink, "#")(0) '??
MsgBox strLink

' copy this file to C:\Damo folder (as file type not only the name)

Rs.MoveNext
Loop

Rs.Close
End Sub
========================================


:

If you have a table of hyperlinks and want to save them to a file then:

Sub Macro1()
With ActiveWorkbook
.SaveAs Filename:="C:\Damo\Book1.htm", FileFormat:=xlHtml
End With
End Sub

This will create an html file with all the links in it. It is also possible
to create single files with a link in each one with VBA.
--
Gary''s Student - gsnu200728


:

Hi,
Hoe to loop through all the hyperlink in my table? by button click event in
vba
Thank's,
I want to get all this links and save them in my computer at C:\Damo
How can I do this?
I'm new in vba
Yael.
 
Top