Avatar billede titwenty Nybegynder
25. august 2008 - 18:33 Der er 22 kommentarer og
1 løsning

Åbne fil via hyperlink i bestemt program?

Jeg har lavet en database over de karaokesange jeg har liggende på PC'en. Filerne er allesammen .zip filer som kan åbnes direkte i afspilleren KaraFun (www.karafun.com).

I tabellen har jeg lavet en kolonne med hyperlink til den enkeltefil og når jeg bruger denne i et skema går det fint at åbne disse i winrar, men....

Jeg vil jo gerne have at når man klikker på linken bliver filen åbnet i C:\Program Files\KaraFun\KaraFun.exe, men det kan jeg ikke få til at fungere.

Har prøvet at lægge en funktion in som hedder "Shell "C:\Program Files\KaraFun\KaraFun.exe" og programmet åbner, men når jeg lukker det igen bliver filen åbnet i winrar som sædvanlig.

Jeg er jo ikke interesseret i at assosiere .zip med et andet program og derfor er mit spørgsmål:

Hvordan kan jeg give Access besked om at når man klikke på hyperlinken skal den åbne filen i et bestemt program? (C:\Program Files\KaraFun\KaraFun.exe)

Jeh håber der er nogle hajer derude som kan hjælpe mig lidt på vej, da jeg ikke har så meget forstand på de funktioner.
Avatar billede terry Ekspert
25. august 2008 - 19:33 #1
try using shellexec
http://www.mvps.org/access/api/api0018.htm

This opens a file with the associated application.
Avatar billede titwenty Nybegynder
25. august 2008 - 19:36 #2
I have already seen that one. But the problem is that I DON'T want to open it in the associated application but the one named C:\Program Files\KaraFun\KaraFun.exe.

Any ideas?
Avatar billede terry Ekspert
25. august 2008 - 19:37 #3
The reason why the files get opened with WinRar is because the is the program which zip files are associated with. You will need to alter this to KaraFun.exe if you want to open ZIP filed with this and not WinRar
Avatar billede terry Ekspert
25. august 2008 - 19:39 #4
Didnt see your comment 25/08-2008 19:36:36

If you use Shell .... cant you add the file name?
EG:
Shell "C:\Program Files\KaraFun\KaraFun.exe" SomeFileNameGoesHere?
Avatar billede titwenty Nybegynder
25. august 2008 - 19:42 #5
I thougt so too. I got so far that it opens karafun when clicked, but the file itself is not opened. The problem is probably to figure out what to put in "SomeFileNameGoesHere?".
The filename should be the hyperlink that is in the column "Fil" in the associated table to make it perfect.
Avatar billede terry Ekspert
25. august 2008 - 19:44 #6
Well I dont have the program ..karafun.exe I would think the full path\filename should work

C:\Path\Filename
Avatar billede terry Ekspert
25. august 2008 - 19:48 #7
Try hardcoding your shell code with a path\filename and see if you can get that working first
Avatar billede titwenty Nybegynder
25. august 2008 - 19:51 #8
It should work because when I choose "Open with.." in explorer and open the .zip in Karafun it works perfect.

Do you mean it should be something like

Shell "C:\Program Files\KaraFun\KaraFun.exe c:/path/filename" ??

How do I exchange the "c:/path/filename" with the field value of the post in question so it will open the file listen in every post?

Thanks a lot for your help....
Avatar billede titwenty Nybegynder
25. august 2008 - 19:56 #9
I tried hardcoding this:

Shell "C:\Program Files\KaraFun\KaraFun.exe""E:\Karaoke offers\_Danish songs\Shubidua - Vuffelivov - (ASK08-13).zip"

It says "file not found". Is the syntax wrong? I'm so new to this coding, but this procedure would be extremely nice to have...
Avatar billede terry Ekspert
25. august 2008 - 19:58 #10
I think you shuld try hardcoding it, or directly in th edebug window (CTRL+G)

Yes, something like
Shell "C:\Program Files\KaraFun\KaraFun.exe c:\path\filename"
Avatar billede terry Ekspert
25. august 2008 - 19:59 #11
once we know that you can open a file using shell in code the we can work out how to open the file in the current record
Avatar billede terry Ekspert
25. august 2008 - 20:06 #12
Maybe
Shell "C:\Program Files\KaraFun\KaraFun.exe E:\Karaoke offers\_Danish songs\Shubidua - Vuffelivov - (ASK08-13).zip"
Avatar billede terry Ekspert
25. august 2008 - 20:07 #13
I would try keeping the path\filename simple to start with
Avatar billede titwenty Nybegynder
25. august 2008 - 20:15 #14
Getting close.

When I use the syntax:

Shell "C:\Program Files\KaraFun\KaraFun.exe ""E:\Karaoke offers\_Danish songs\Shubidua - Vuffelivov - (ASK08-13).zip"""

it works perfectly. I found that I needed the double "" if there are spaces in the filename.

So...if you can just help me using the value of the "Fil" field instead of my hardcoded filename I will be a very happy man.
Avatar billede terry Ekspert
25. august 2008 - 20:22 #15
Well assuming that a record is selected then something like this.
You will need to play areound with those "" I think

Shell "C:\Program Files\KaraFun\KaraFun.exe "" & me.Fil & """

(No need to reject/accept the answer untill you close the question)
Avatar billede titwenty Nybegynder
25. august 2008 - 20:35 #16
Hmmm...trying all combinations to no avail. I will keep trying, but please let me know if you suddenly think about a solution :-)

(Sorry for rejecting - was a bit too fast on the keys)
Avatar billede terry Ekspert
25. august 2008 - 20:40 #17
We are on the right track, it sjust a case of getting the filename into the shell line

In your code place a breakpoint on th eline with shell in it, the run to the breakpoint.

Then try writing this in the debug window (CTRL+G)


Debug.print Shell "C:\Program Files\KaraFun\KaraFun.exe "" & me.Fil & """

It should look like the line you gave above but without the first and last "

C:\Program Files\KaraFun\KaraFun.exe ""E:\Karaoke offers\_Danish songs\Shubidua - Vuffelivov - (ASK08-13).zip""
Avatar billede terry Ekspert
25. august 2008 - 20:40 #18
I'm off out with th edigs for a walk, back in a short while
Avatar billede titwenty Nybegynder
25. august 2008 - 20:51 #19
I don't get the debug to work. I might do it wrong. I'll try some more and write the result here if anything changes. Thanks :-)
Avatar billede terry Ekspert
25. august 2008 - 21:12 #20
sorry, the debug.print is wrong :o(

Debug.print Shell "C:\Program Files\KaraFun\KaraFun.exe "" & me.Fil & """

WITHOUT shell
Avatar billede titwenty Nybegynder
25. august 2008 - 21:26 #21
HEUREKA!!!

The correct syntax is:

Shell "C:\Program Files\KaraFun\KaraFun.exe """ & Me.Fil & """"

then it works.

It doesn't work when the field contains a hyperling to the file as the result will be that #x:/path/filename# is added to the end, so the solution is not 100% good, but it works for me as I can work around this problem or solve it later.

Thanks a lot terry!!!!
Avatar billede terry Ekspert
26. august 2008 - 08:20 #22
Not sure how your adding the hyperlink to the field but you could use the commond dialog control (File open) and save the path/filename in your dB instead of the hyperlink.

And thanks for the points.
Avatar billede titwenty Nybegynder
26. august 2008 - 10:59 #23
terry, that is exactly how I did it. I will work with the hyperlink though as I think that would be a better solution - but it's not that important. Now I just need to put in the last 5000 songs in my database.

Thanks a lot for setting me on the right track here - I was very close to the solution, but it's always the last mile that's hard.
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Dyk ned i databasernes verden på et af vores praksisnære Access-kurser

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester