473,322 Members | 1,718 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

how to create a shortcut of mdb in desktop using code

AR Ratheesh
Hi guys,
can you help me to create my mdb file shortcut in desktop using code...
Oct 4 '09 #1

✓ answered by ADezii

I've modified you original code so that a Shortcut to the 'Current Database' will be created on the Desktop, simply change the value of the conSHORTCUT_NAME CONSTANT to suit your needs. The Shortcut points directly to the *.mdb File since the Sever Application (Microsoft Access) will automatically Open this File given its Extension. Is this what you were after?
Expand|Select|Wrap|Line Numbers
  1. Dim WSHShell As Object
  2. Set WSHShell = CreateObject("WScript.Shell")
  3.  
  4. Dim MyShortcut As Object
  5. Dim DesktopPath As String
  6.  
  7. 'Personalize
  8. Const conSHORTCUT_NAME As String = "Display Name of Shortcut"
  9.  
  10. ' Read desktop path using WshSpecialFolders object
  11. DesktopPath = WSHShell.SpecialFolders("Desktop")
  12.  
  13. ' Create a shortcut object on the desktop
  14. Set MyShortcut = WSHShell.CreateShortcut(DesktopPath & "\" & conSHORTCUT_NAME & ".lnk")
  15.  
  16. ' Set shortcut object properties and save it
  17. MyShortcut.TargetPath = WSHShell.ExpandEnvironmentStrings(CurrentProject.Path & _
  18.                                  "\" & CurrentProject.Name)
  19. MyShortcut.WorkingDirectory = WSHShell.ExpandEnvironmentStrings(CurrentProject.Path)
  20. MyShortcut.WindowStyle = 4
  21. MyShortcut.Save
  22.  
  23. Set MyShortcut = Nothing
  24. Set WSHShell = Nothing

6 7476
NeoPa
32,556 Expert Mod 16PB
I think you need some Windows help here first AR.

I'm not aware of any such library function available in Access.

I'll leave it here for now, in case any Access expert has the requisite Windows knowledge, but if/when you let me know you'd like it moved across, then I will do that for you.
Oct 4 '09 #2
I got this code for creating shortcut for notepad.exe
Expand|Select|Wrap|Line Numbers
  1. Private Sub Command0_Click()
  2. Dim WSHShell As Object
  3. Set WSHShell = CreateObject("WScript.Shell")
  4.  
  5. Dim MyShortcut As Object
  6. Dim DesktopPath As String
  7.  
  8. ' Read desktop path using WshSpecialFolders object
  9. DesktopPath = WSHShell.SpecialFolders("Desktop")
  10.  
  11. ' Create a shortcut object on the desktop
  12. Set MyShortcut = WSHShell.CreateShortcut(DesktopPath & _
  13. "\Mytrial.lnk")
  14.  
  15. ' Set shortcut object properties and save it
  16. MyShortcut.TargetPath = WSHShell.ExpandEnvironmentStrings("%windir%\notepa d.exe")
  17. MyShortcut.WorkingDirectory = WSHShell.ExpandEnvironmentStrings("%windir%")
  18. MyShortcut.WindowStyle = 4
  19. MyShortcut.IconLocation = _
  20. WSHShell.ExpandEnvironmentStrings("%windir%\notepa d.exe, 0")
  21. MyShortcut.Save
  22.  
  23. Set MyShortcut = Nothing
  24. Set WSHShell = Nothing
  25. End Sub
I think if we change the path thats may works better,sorry i dont try like that...
Thank u for ur reply.....
Oct 4 '09 #3
NeoPa
32,556 Expert Mod 16PB
I assume you're happy now that you have what you require?
Oct 4 '09 #4
ADezii
8,834 Expert 8TB
I've modified you original code so that a Shortcut to the 'Current Database' will be created on the Desktop, simply change the value of the conSHORTCUT_NAME CONSTANT to suit your needs. The Shortcut points directly to the *.mdb File since the Sever Application (Microsoft Access) will automatically Open this File given its Extension. Is this what you were after?
Expand|Select|Wrap|Line Numbers
  1. Dim WSHShell As Object
  2. Set WSHShell = CreateObject("WScript.Shell")
  3.  
  4. Dim MyShortcut As Object
  5. Dim DesktopPath As String
  6.  
  7. 'Personalize
  8. Const conSHORTCUT_NAME As String = "Display Name of Shortcut"
  9.  
  10. ' Read desktop path using WshSpecialFolders object
  11. DesktopPath = WSHShell.SpecialFolders("Desktop")
  12.  
  13. ' Create a shortcut object on the desktop
  14. Set MyShortcut = WSHShell.CreateShortcut(DesktopPath & "\" & conSHORTCUT_NAME & ".lnk")
  15.  
  16. ' Set shortcut object properties and save it
  17. MyShortcut.TargetPath = WSHShell.ExpandEnvironmentStrings(CurrentProject.Path & _
  18.                                  "\" & CurrentProject.Name)
  19. MyShortcut.WorkingDirectory = WSHShell.ExpandEnvironmentStrings(CurrentProject.Path)
  20. MyShortcut.WindowStyle = 4
  21. MyShortcut.Save
  22.  
  23. Set MyShortcut = Nothing
  24. Set WSHShell = Nothing
Oct 4 '09 #5
Thank u Adezii,
Successfully created my job.thanks again....
Oct 5 '09 #6
ADezii
8,834 Expert 8TB
@AR Ratheesh
You are quite welcome. You made this one very easy, you supplied the Base Code! (LOL)!
Oct 5 '09 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Eskimo Joe | last post by:
I am trying to create a desktop icon using VB6. is this possible? -p
1
by: Tom | last post by:
I created an msi using the Setup Wizard, but don't seem to be able to create a shortcut to the applicaton on the desktop (or prompt for one) or the menu. Also, I would like to add an "uninstall"...
4
by: I_AM_DON_AND_YOU? | last post by:
There is one more problem I am facing but didn't get the solution. In my Setup Program I am not been able to create 2 things (when the program is intalled on the client machine ) : (1) create...
3
by: Michael D. Murphy | last post by:
Hi, I am searching for a way to creat desktop shortcuts when running the setup files that were created within a VB solution using the setup wizard. Thanks, Michael
7
by: GrandpaB | last post by:
I would appreciate assistance learning how to create a Desktop shortcut in my setup project. In the left pane of the Setup/File System window I right-clicked User's Desktop. From the contex...
3
by: baroque Chou | last post by:
We build a web site and have some registred user, we want to offer such a feature that the user can access our site from his or her desktop shortcut and want it be log on automatic. So I plan to...
0
by: peter.bittner | last post by:
I have developed a Windows application in Visual Studio .NET 2003 and created a Setup project for it. In the File System Editor I have added a shortcut to the User's Desktop folder to point to the...
3
by: thi | last post by:
Hi, How do i create an application shortcut on desktop programmically in C#? I have done some shortcut coding before in visual basic 6 using windows scripting host but later found out that...
3
by: sanghavi | last post by:
how to create a set up project in vb.net..how to run an application on a different machine
1
by: Mosa | last post by:
Dear all, I want to create a desktop shortcut using this code function MakeShortcut() { var WshShell = new ActiveXObject("WScript.Shell"); strDesktop = WshShell.SpecialFolders("Desktop");...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.