Cinereo
asked on
Need help changing simple VBS script to VBA
Hi.
I'm sure this is really simple for those who know, but I'm having some trouble as I'm a week old with VBS and with using VBA to run Shell functions.
I need to rewrite this VBS into VBA format for an Access 2007 application.
Its function: to install an existing font from the application's working folder (not WinDir\Fonts)
O/S: All installed machines (now and future) will be Windows 7 or higher.
Note:
1. All referenced variables, like WSHshell, are declared earlier in the VBA Sub.
2. "Cup" is standard for this app and used throughout.
3. The font already exists in the Working Folder (see objFolder - where the FE lives)
'===========VBS=========== ==
set wshShell = CreateObject ("WScript.Shell")
Cup = wshShell.ExpandEnvironment Strings("% UserProfil e%")
set objShell = CreateObject("Shell.Applic ation")
set objFolder = objShell.Namespace(Cup & "\AppData\Roaming\Cinereo\ ")
set objFolderItem = objFolder.ParseName("CINER EO.TTF")
objFolderItem.InvokeVerb(" Install")
set objShell = nothing
set wshShell = nothing
'=============VBA======== ??????
Thanks to everyone who even takes a look. Your interest is appreciated.
I'm sure this is really simple for those who know, but I'm having some trouble as I'm a week old with VBS and with using VBA to run Shell functions.
I need to rewrite this VBS into VBA format for an Access 2007 application.
Its function: to install an existing font from the application's working folder (not WinDir\Fonts)
O/S: All installed machines (now and future) will be Windows 7 or higher.
Note:
1. All referenced variables, like WSHshell, are declared earlier in the VBA Sub.
2. "Cup" is standard for this app and used throughout.
3. The font already exists in the Working Folder (see objFolder - where the FE lives)
'===========VBS===========
set wshShell = CreateObject ("WScript.Shell")
Cup = wshShell.ExpandEnvironment
set objShell = CreateObject("Shell.Applic
set objFolder = objShell.Namespace(Cup & "\AppData\Roaming\Cinereo\
set objFolderItem = objFolder.ParseName("CINER
objFolderItem.InvokeVerb("
set objShell = nothing
set wshShell = nothing
'=============VBA======== ??????
Thanks to everyone who even takes a look. Your interest is appreciated.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Capricorn1's code worked perfectly - on its own. Which tells me the problem is elsewhere.
So I went scrolling through numerous lines of code (this post is a small section of the entire subroutine). Found where Cup was reassigned its own value PLUS surrounding double quotations. Seems that's used for setting up the shortcuts. But tripped this portion. Just had to move things around.
Issue is now resolved. Capricorn1, thanks so much for the assist.
Mbizup, thanks too for expanding on my understanding of the two types of code. Very helpful.
Cheers,