Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Word: A Link that Opens a File but Not via the Main Association 1

Status
Not open for further replies.

GGleason

Technical User
Mar 22, 2001
321
US
Is it possible to have a link within Word where you can open a file with another application? Suppose you have a file with a .reg extension. If you created a link to that file it would want to run the file into the registry. But what if you wanted a link to open it in Notepad? That is what I am trying to do.

Any suggestions?

tia,
GGleason
 
Maybe I'm oversimplifying this, but why not save it in Notepad as a .txt file.
Insert your link to said file.
When you click on it in the Word doc, it will open in Notepad. (At least this works when I try it.)

Tired of waiting for an answer? Try asking better questions. See: faq222-2244
 
While that is a solution, it is not one that will work in this instance. It is breaking the data normalization rule and I have way too many files to keep up with without having duplicates to worry about.

Thanks,
GGleason
 
Ok. I posed an answer specific to your given example...what exactly is it tht you're trying to pull off? Can you lay out the situation a little more explicitly. How is this inherently going to create duplicates and where does data normalization fit in here?

Tired of waiting for an answer? Try asking better questions. See: faq222-2244
 
carrr,

What I am looking for is something kin to VBA shell where you can specify an app and a file name to launch it. In my example it would be:

lngProc = Shell(“Notepad “ + strPathFile)

It seems like it should be possible to a link or something similar within Word w/o having to go through a lot coding gymnastics.

Pardon my metaphor mixing. Data normalization is more of a database concept where you don’t want to have multiple instances of the same information, causing confusion on what is the latest or valid information. I am applying that same concept to files. I don’t want 2 files with the same confession. There I go mixing metaphors again …

GGleason
 
Hi GGleason,

Isn't that what you get with a HYPERLINK field that points to an external object?

A LINK field works similarly also, except that the object is visible within the Word document itself, as do other embedded objects, which run the associated application whenever you want to edit them.

Cheers
 
All,

What I am looking for is the same as calling up the Run command prompt and putting in "Notepad MyJournal.html". Rather than the link launching in the associated app (i.e., Internet Explorer) it would launch with Notepad. I am just looking for the syntax to do that within Word.

Still looking for a solution ...

GGleason
 
Hi GGleason,

AFAIK you can't control the app used with VBA, or anything else. There might be a way round it however - if you create your own 'links' with a button and in the code behind the button you open whatever file with whatever app you wanted. It might not be quite the same but it would be pretty close.

Enjoy,
Tony

--------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.
Excel VBA Training and more Help at VBAExpress[
 
Tony,

Thanks for the the tip and you get a star. I made a command button and put the VBA behind it and it finally did what I wanted it to do.

It is not an elegant solution, but it is an acceptable one.

Thanks,
GGleason
 
Actually, you CAN control the app used by a hyperlink, but I can not not seem to be able to pass a filename to it.

{HYPERLINK "C:\\Windows\\notepad.exe"} will open a blank Notepad document.

However, {HYPERLINK "C:\\Windows\\notepad.exe "c:\temp\test.txt""} does not open the file. It opens a blank notepad doc. No error is returned. Hyperlinks seem to be able to accept one parameter - the file location. In this case, the file is the executable notepad.exe. Every thing after that seems to be ignored.

Notepad.exe "c:\temp\test.txt" from a command line DOES pass the filename. So Hyperlinks are not like Shell, or Run....kinda. If someone knows how to pass a parameter into HYPERLINK I would like to know it as well.



Gerry
See my Paintings and Sculpture
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top