Create a Shortcut in ms access vba

I would like to create a shortcut in vba to install fonts here's the info

argument=C:\myfolder\myfolder1\myfolder2\RegisterFont.exe add TEXASLED.ttf bold_led_board-7.ttf Codystar-Regular.ttf Codystar-Light.ttf enhanced_led_board-7.ttf
tagetpath=C:\myfolder\myfolder1\myfolder2

the program name is RegisterFont.exe located in the C:\myfolder\myfolder1\myfolder2 folder
thanks
SvgmassiveAsked:
Who is Participating?
 
Bill PrewConnect With a Mentor Commented:
Are you looking for a shortcut (.LNK file) to be created so that the user can double click on it and it will run that EXE program with those parms?  If so, do you want the .LNK file located on the Desktop, or actually placed in the same folder as the EXE (C:\myfolder\myfolder1\myfolder2)?

If trying to create a shortcut on the desktop to launch that program then try this:

Sub CreateShortcut()
    Dim objShell As Object

    Dim myCommand As String
    Dim myParms As String
    Dim myFolder As String

    myCommand = "C:\myfolder\myfolder1\myfolder2\RegisterFont.exe"
    myParms = "add TEXASLED.ttf bold_led_board-7.ttf Codystar-Regular.ttf Codystar-Light.ttf enhanced_led_board-7.ttf"
    myFolder = "C:\myfolder\myfolder1\myfolder2"
    
    Set objShell = CreateObject("WScript.Shell")
    
    With objShell.CreateShortcut(objShell.SpecialFolders("Desktop") & "\AddFont.lnk")
        .Targetpath = myCommand
        .Arguments = myParms
        .WorkingDirectory = myFolder
        .Save
    End With

    Set objShell = Nothing
End Sub

Open in new window


»bp
0
 
PatHartmanCommented:
I don't understand why you would need to create a shortcut to install the fonts.  Why not just install them.  It would make sense to create a shortcut if this were something that needed to be run regularly but once the fonts are installed, they are installed and there would be no further use for the shortcut.
1
 
PatHartmanCommented:
Svgmassive, you endorsed my comment.  Does that mean that you are trying to close the question?
0
 
SvgmassiveAuthor Commented:
I tested on 32bit just wanted to ensure that it worked on 64bit.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.