Create Shortcut with own icon (1 Viewer)

isladogs

MVP / VIP
Local time
Today, 13:26
Joined
Jan 14, 2017
Messages
18,219
Excellent.
Gasman's suggestion for placing the vbs file in the startup folder was also a good idea.

Good luck with the rest of your project
 

gstylianou

Registered User.
Local time
Today, 15:26
Joined
Dec 16, 2013
Messages
357
Excellent.
Gasman's suggestion for placing the vbs file in the startup folder was also a good idea.

Good luck with the rest of your project

dear friend isladoc, how can placing the vbs file in the startup folder?
 

Gasman

Enthusiastic Amateur
Local time
Today, 13:26
Joined
Sep 21, 2011
Messages
14,288
dear friend isladoc, how can placing the vbs file in the startup folder?

You will likely need a cmd file to run the vbs file.

Just put in the yourfilename.cmd file

Code:
wscript <your vbsfilename with path>

HTH
 

gstylianou

Registered User.
Local time
Today, 15:26
Joined
Dec 16, 2013
Messages
357
You will likely need a cmd file to run the vbs file.

Just put in the yourfilename.cmd file

Code:
wscript <your vbsfilename with path>

HTH

Gasman you mean to create a new cmd file which includes inside your line of code?

And another last question, is it possible to run the code to create shortcut without open the target database?
 

Gasman

Enthusiastic Amateur
Local time
Today, 13:26
Joined
Sep 21, 2011
Messages
14,288
Yes, the cmd file will be executed if in the startup folder.
You can also use a shortcut. Whatever you are most comfortable with

That will then run the vbs script to create the shortcut.

the VBS is almost identical to the VBA

Code:
    ' Based on code from https://msdn.microsoft.com/en-us/library/xsy6k3ys(v=vs.84).aspx
    Dim WshShell
    Dim strDesktop
    Dim oShellLink
    
    Set WshShell = CreateObject("WScript.Shell")
    strDesktop = WshShell.SpecialFolders("Desktop")
   
    Set oShellLink = WshShell.CreateShortcut(strDesktop & "\TestShortcut.lnk") 'modify as appropriate
    
    'modify each of the values as appropriate
    With oShellLink
         .TargetPath = "C:\Users\Public\YourFileName.accdb"
         .WindowStyle = 1
        '.Hotkey = "Ctrl+Alt+f" 'optional
         '.IconLocation = "notepad.exe, 0"  ' for embedded icon
         .IconLocation = "C:\__tmp\MIME\foo.ico"  ' for specified .ico file
         .Description = "My shortcut created by VBA" 'optional
         .WorkingDirectory = strDesktop
         '.Arguments = "C:\myFile.txt"  'optional
         .Save
    End With

The VBS method means no DB is required.

My wscript.exe is in c:\Windows\System32 folder

HTH
 

gstylianou

Registered User.
Local time
Today, 15:26
Joined
Dec 16, 2013
Messages
357
Excellent.
Gasman's suggestion for placing the vbs file in the startup folder was also a good idea.

Good luck with the rest of your project

Hello again,

Problem...problem.! The code is working fine as i told before but after the creation of the shortcut the my database is loading maximized....and user must select the maximize from window dialog every time when use the shortcut...

Sure is something simple..
 

Attachments

  • PROBLEM.JPG
    PROBLEM.JPG
    39.5 KB · Views: 56

gstylianou

Registered User.
Local time
Today, 15:26
Joined
Dec 16, 2013
Messages
357
So are you saying, if you open it manually it is maximised automatically?

Isladogs will know what to do there.

Yes, if i open the file from file location is open normally...and if i use the shortcut not..hope to solve the problem
 

Gasman

Enthusiastic Amateur
Local time
Today, 13:26
Joined
Sep 21, 2011
Messages
14,288
If you are talking about the app window, then change WindowStyle to 3
 

Users who are viewing this thread

Top Bottom