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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access 2000: Open all hyperlinks in notepad...

Status
Not open for further replies.

MasterTraveler

Programmer
Oct 17, 2006
3
0
0
US
Hello. This is a seemingly simple thing that has been driving me batty for the last couple of days.

I have a database (Access 2000) full of hyperlinks to files located on a network drive. Some of the files are ".txt", but most are not. The files I'm working with have all different kinds of extensions (or no extension at all), but all contain plain text. When I open a hyperlink to a file with the ".txt" extension, it opens in Notepad without any problems. However, when a hyperlink to a non-txt file is clicked, Access does not even attempt to open the file. Instead it displays this message:

"Unable to open G:\path_to_file\filename.rtdiojn. No program is registered to open this file."

It would be nice if I had the option to open the file in the editor of my choosing, but I've looked everywhere for an option like this and it does not seem to exist. The extension varies from file to file most of the time, as many are randomly generated, so I cannot assign Windows to associate them with Notepad. I'm not allowed to tamper with the files themselves either, so changing all the files to ".txt" is also not an option.

I was thinking maybe a macro or VB script of some type. Anyone have any ideas, or had success with a similar issue?
 
Thanks for replying pwise.

I'm trying out what you suggested. Here's what I'm doing so far:

- I make a new macro.
- I use the option RunCode.
- In the Expression Builder, I type Shell(notepad, <<windowstyle>>)

Can you please clarify how to pull the hyperlink value from the clicked field and set it to the <<windowstyle>> argument?

Thanks.
 
The extension varies from file to file most of the time, as many are randomly generated

That makes no sense to me. Is

filename.rtdiojn

one of the randomly generated file extension? You can use the shell function something like this.

Dim reVal
reVal = Shell("C:\Windows\Notepad.exe ""C:\My Documents\myFile.doc""")

That will open myFile.doc in Notepad. But I don't see how anything with a file extension like your example will work. Notepad will open it, but it will probably look like gobbly gook.
Can you tell us more.

Paul
 
Yes, sorry for making this sound more complicated that it is.

All the files are plain-text, and therefore open fine in Notepad, so I'm not worried about 'gobbly gook' as you put. :)

However, there is a specific naming convention our company uses with all of these data files. Therefore, the vast majority of them extensions that appear to be random series of characters.

So as a workaround, I just want to find a way to force Access to always open these hyperlinked files in Notepad.

I'm getting close to solving it, actually. I made a form that populates a listbox with the hyperlinks, and set up a button so that it runs a script for the selected row when clicked:

Call Shell("NOTEPAD.EXE " & fileName, vbNormalFocus)

Now I just need to set my string variable, 'fileName' to the text value in the selected row. Haven't figured it out yet.
 
The easiest way might be to write the value in the list box to a textbox (visible or not), and then grab the value of the textbox in your filename string. The syntax for getting the value of the listbox into a string is a little more difficult than grabbing it from a textbox.
Post back if you need help with that.

Paul
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top