ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Paste a hyperlink (https://www.excelbanter.com/excel-programming/326665-paste-hyperlink.html)

quartz[_2_]

Paste a hyperlink
 
I have a the full name of a file in a string variable. I need example code on
how to paste it into a cell as a hyperlink, so that if it is clicked the file
will open in its native format (i.e. Excel in Excel, Word in Word, etc.).

I tried to record it, but that doesn't work. Can somone please help me out?

Thanks much in advance.

Dick Kusleika[_4_]

Paste a hyperlink
 
quartz

Try this


Sub test()

Dim sVar As String

sVar = "c:\book1.xls"

With Sheet1.Range("A1")
.Hyperlinks.Add .Cells(1, 1), sVar
End With

End Sub


--
Dick Kusleika
Excel MVP
Daily Dose of Excel
www.dicks-blog.com

quartz wrote:
I have a the full name of a file in a string variable. I need example
code on how to paste it into a cell as a hyperlink, so that if it is
clicked the file will open in its native format (i.e. Excel in Excel,
Word in Word, etc.).

I tried to record it, but that doesn't work. Can somone please help
me out?

Thanks much in advance.




dollardoc

Paste a hyperlink if cell contains XXXX...
 
Partly answers my dilemma. I have a form with 20 lines that uses a macro to
paste into a database. In Cell D18 it can be either text or a hyperlink.
Problem is that the macro pastes the hyperlink in D18 to DBase as text
instead of the link. 1) how do you add the IF THEN to determine if the text
is actual hyperlink and then paste it as such, or 2) if I make the cell only
available for hyperlinks, how to get it copied to DBase if cell has link in
it, or if cell is blank? thanx 4 this great service. tom dollardoc

"Dick Kusleika" wrote in message
...
quartz
Try this
Sub test()
Dim sVar As String
sVar = "c:\book1.xls"
With Sheet1.Range("A1")

.Hyperlinks.Add .Cells(1, 1), sVar 'Does this format cell a
Hyperlink?'
End With

End Sub
--

Dick Kusleika
Excel MVP
Daily Dose of Excel
www.dicks-blog.com

quartz wrote:
I have a the full name of a file in a string variable. I need example
code on how to paste it into a cell as a hyperlink, so that if it is
clicked the file will open in its native format (i.e. Excel in Excel,
Word in Word, etc.).

I tried to record it, but that doesn't work. Can somone please help
me out?

Thanks much in advance.






Dick Kusleika[_4_]

Paste a hyperlink if cell contains XXXX...
 
Tom

Are you talking about Dbase the database program? I have no idea how to
paste into dbase so it's a hyperlink. How are you pasting in there as text
now?

--
Dick Kusleika
Excel MVP
Daily Dose of Excel
www.dicks-blog.com

dollardoc wrote:
Partly answers my dilemma. I have a form with 20 lines that uses a
macro to paste into a database. In Cell D18 it can be either text or
a hyperlink. Problem is that the macro pastes the hyperlink in D18 to
DBase as text instead of the link. 1) how do you add the IF THEN to
determine if the text is actual hyperlink and then paste it as such,
or 2) if I make the cell only available for hyperlinks, how to get it
copied to DBase if cell has link in it, or if cell is blank? thanx 4
this great service. tom dollardoc
"Dick Kusleika" wrote in message
...
quartz
Try this
Sub test()
Dim sVar As String
sVar = "c:\book1.xls"
With Sheet1.Range("A1")

.Hyperlinks.Add .Cells(1, 1), sVar 'Does this format cell a
Hyperlink?'
End With

End Sub
--

Dick Kusleika
Excel MVP
Daily Dose of Excel
www.dicks-blog.com

quartz wrote:
I have a the full name of a file in a string variable. I need
example code on how to paste it into a cell as a hyperlink, so that
if it is clicked the file will open in its native format (i.e.
Excel in Excel, Word in Word, etc.).

I tried to record it, but that doesn't work. Can somone please help
me out?

Thanks much in advance.





All times are GMT +1. The time now is 11:36 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com