ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Desktop icon (https://www.excelbanter.com/excel-programming/438502-desktop-icon.html)

Oldjay

Desktop icon
 
Can I call Access from a desktop short with with VBA

joel[_568_]

Desktop icon
 

You need to run the DLL ShellExecute. I assumed the Icon was in you
poersonnal DeskTop and not the All Users. I tested with Spybot but you
can use any ICON.



Const SW_SHOW = 1
Const SW_SHOWMAXIMIZED = 3

Public Declare Function ShellExecute Lib "Shell32.dll" Alias
"ShellExecuteA" _
(ByVal hwnd As Long, _
ByVal lpOperation As String, _
ByVal lpFile As String, _
ByVal lpParameters As String, _
ByVal lpDirectory As String, _
ByVal nShowCmd As Long) As Long


Sub test()

IConName = "Spybot - Search & Destroy"

HomePath = Environ("HomeDrive") & Environ("Homepath")
DeskTop = HomePath & "\" & "DeskTop"


RetVal = ShellExecute(0, "open", IConName, "<arguments", _
DeskTop, SW_SHOWMAXIMIZED)


End Sub


--
joel
------------------------------------------------------------------------
joel's Profile: 229
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=170758

Microsoft Office Help


Oldjay

Desktop icon
 
I get the following compile error when I try to run this
"Constants,fixed- length strings,arrays, user dedined type and Declare
statementsnot allowed as Public member of object modules"

Const SW_SHOW = 1
Const SW_SHOWMAXIMIZED = 3

Public Declare Function ShellExecute Lib "Shell32.dll" Alias "ShellExecuteA" _
(ByVal hwnd As Long, _
ByVal lpOperation As String, _
ByVal lpFile As String, _
ByVal lpParameters As String, _
ByVal lpDirectory As String, _
ByVal nShowCmd As Long) As Long


Sub test()

IConName = "Customers.mdb - Shortcut"

HomePath = Environ("HomeDrive") & Environ("Homepath")
DeskTop = HomePath & "\" & "DeskTop"


RetVal = ShellExecute(0, "open", IConName, "<arguments", _
DeskTop, SW_SHOWMAXIMIZED)


End Sub

"joel" wrote:


You need to run the DLL ShellExecute. I assumed the Icon was in you
poersonnal DeskTop and not the All Users. I tested with Spybot but you
can use any ICON.



Const SW_SHOW = 1
Const SW_SHOWMAXIMIZED = 3

Public Declare Function ShellExecute Lib "Shell32.dll" Alias
"ShellExecuteA" _
(ByVal hwnd As Long, _
ByVal lpOperation As String, _
ByVal lpFile As String, _
ByVal lpParameters As String, _
ByVal lpDirectory As String, _
ByVal nShowCmd As Long) As Long


Sub test()

IConName = "Spybot - Search & Destroy"

HomePath = Environ("HomeDrive") & Environ("Homepath")
DeskTop = HomePath & "\" & "DeskTop"


RetVal = ShellExecute(0, "open", IConName, "<arguments", _
DeskTop, SW_SHOWMAXIMIZED)


End Sub


--
joel
------------------------------------------------------------------------
joel's Profile: 229
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=170758

Microsoft Office Help

.


joel[_572_]

Desktop icon
 

I copied the code exactly from the posting and did not get any errors.
Put the code below on a new module exactly as posted and see if you get
any errors with no other macros. I put the code in a VBA module. theis
code should work in excel 2000 and above.

Const SW_SHOW = 1
Const SW_SHOWMAXIMIZED = 3

Public Declare Function ShellExecute Lib "Shell32.dll" Alias
"ShellExecuteA" _
(ByVal hwnd As Long, _
ByVal lpOperation As String, _
ByVal lpFile As String, _
ByVal lpParameters As String, _
ByVal lpDirectory As String, _
ByVal nShowCmd As Long) As Long


Sub test()

IConName = "Customers.mdb - Shortcut"

HomePath = Environ("HomeDrive") & Environ("Homepath")
DeskTop = HomePath & "\" & "DeskTop"


RetVal = ShellExecute(0, "open", IConName, "<arguments", _
DeskTop, SW_SHOWMAXIMIZED)


End Sub

"joel" wrote:


You need to run the DLL ShellExecute. I assumed the Icon was in you
poersonnal DeskTop and not the All Users. I tested with Spybot but

you
can use any ICON.



Const SW_SHOW = 1
Const SW_SHOWMAXIMIZED = 3

Public Declare Function ShellExecute Lib "Shell32.dll" Alias
"ShellExecuteA" _
(ByVal hwnd As Long, _
ByVal lpOperation As String, _
ByVal lpFile As String, _
ByVal lpParameters As String, _
ByVal lpDirectory As String, _
ByVal nShowCmd As Long) As Long


Sub test()

IConName = "Spybot - Search & Destroy"

HomePath = Environ("HomeDrive") & Environ("Homepath")
DeskTop = HomePath & "\" & "DeskTop"


RetVal = ShellExecute(0, "open", IConName, "<arguments", _
DeskTop, SW_SHOWMAXIMIZED)


End Sub


--
joel

------------------------------------------------------------------------
joel's Profile: 229
View this thread: 'Desktop icon - The Code Cage Forums'

(http://www.thecodecage.com/forumz/sh...d.php?t=170758)

'Microsoft Office Help' (http://www.thecodecage.com)

.



--
joel
------------------------------------------------------------------------
joel's Profile: 229
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=170758

Microsoft Office Help



All times are GMT +1. The time now is 05:02 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com