ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Creating a hyperlink in VBA for an autoshape (https://www.excelbanter.com/excel-programming/413726-creating-hyperlink-vba-autoshape.html)

Jim

Creating a hyperlink in VBA for an autoshape
 
ok, so i have created an autoshape on a spreadsheet, I have created a macro
for it and need it to link to a file in another directory. the reason i am
not just creating a "right click--create hyperlink" is because it is getting
screwed up when i run the main program. I want to know how to write it in VB
so it automatically creates the hyperlink thru the macro.

Sub Rectangle5_Click( )
make hyperlink to c:\myfile.doc
End Sub

thanks

Tom Ogilvy

Creating a hyperlink in VBA for an autoshape
 
You want to create a hyperlink or do you want to perform the action a
hyperlink would perform?

--
Regards,
Tom Ogilvy


"Jim" wrote:

ok, so i have created an autoshape on a spreadsheet, I have created a macro
for it and need it to link to a file in another directory. the reason i am
not just creating a "right click--create hyperlink" is because it is getting
screwed up when i run the main program. I want to know how to write it in VB
so it automatically creates the hyperlink thru the macro.

Sub Rectangle5_Click( )
make hyperlink to c:\myfile.doc
End Sub

thanks


Jim

Creating a hyperlink in VBA for an autoshape
 
I want the file to open when I click on the shape and I want to do it thru a
macro. so I guess to answer your question, perform the action that a
hyperlink would.

"Tom Ogilvy" wrote:

You want to create a hyperlink or do you want to perform the action a
hyperlink would perform?

--
Regards,
Tom Ogilvy


"Jim" wrote:

ok, so i have created an autoshape on a spreadsheet, I have created a macro
for it and need it to link to a file in another directory. the reason i am
not just creating a "right click--create hyperlink" is because it is getting
screwed up when i run the main program. I want to know how to write it in VB
so it automatically creates the hyperlink thru the macro.

Sub Rectangle5_Click( )
make hyperlink to c:\myfile.doc
End Sub

thanks


Rick Rothstein \(MVP - VB\)[_2260_]

Creating a hyperlink in VBA for an autoshape
 
Executing this statement should open up your file using the associated
program for its extension (in the case of your original posting, Word should
open up and your myfile.doc document should be loaded automatically)...

Shell Environ("COMSPEC") & " /c ""c:\myfile.doc""", vbHide

Make sure you preserve the spacing and quote marks as shown when
substituting your actual file name in for the sample myfile.doc one.

Rick


"Jim" wrote in message
...
I want the file to open when I click on the shape and I want to do it thru
a
macro. so I guess to answer your question, perform the action that a
hyperlink would.

"Tom Ogilvy" wrote:

You want to create a hyperlink or do you want to perform the action a
hyperlink would perform?

--
Regards,
Tom Ogilvy


"Jim" wrote:

ok, so i have created an autoshape on a spreadsheet, I have created a
macro
for it and need it to link to a file in another directory. the reason i
am
not just creating a "right click--create hyperlink" is because it is
getting
screwed up when i run the main program. I want to know how to write it
in VB
so it automatically creates the hyperlink thru the macro.

Sub Rectangle5_Click( )
make hyperlink to c:\myfile.doc
End Sub

thanks




All times are GMT +1. The time now is 06:23 AM.

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