ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   need command (https://www.excelbanter.com/excel-programming/286701-re-need-command.html)

Russ Robelen[_2_]

need command
 
Is there a way to create a desktop shortcut to an Excel file programmically in VBA? If so could you direct me to the code snippet that accomplishes it

----- Dave Peterson wrote: ----

start "C:\my documents\excel\book1.xls

And put your prerecorded macro in a general module and name it Auto_Open

You could also just create a shortcut to your workbook (on your desktop???) an
then start that, too


MS-DOS wrote
Is there a command I can use to launch excel from DOS

and also have it go right into a pre-recorded macro
thanks


--

Dave Peterso



Dave Peterson[_3_]

need command
 
From a previous post:



If you rightclick on the filename when you're in Windows Explorer, you can
select SendTo. There's an option for Desktop (Create shortcut).

This might help if you want VBA:

Option Explicit
Sub CreateShortCut()

Dim myFileName As String

Dim wsh As Object
Dim SC As Object
Dim myPath As String
Dim myLinkName As String

Set wsh = CreateObject("WScript.Shell")

myPath = wsh.SpecialFolders.Item("Desktop")

myLinkName = "mynicelink.lnk"
myFileName = "C:\my documents\excel\book5.xls"

On Error Resume Next
Kill myPath & "\" & myLinkName
On Error GoTo 0

Set SC = wsh.CreateShortCut(myPath & "\" & myLinkName)

SC.TargetPath = myFileName
SC.Save
Set wsh = Nothing

End Sub


Russ Robelen wrote:

Is there a way to create a desktop shortcut to an Excel file programmically in VBA? If so could you direct me to the code snippet that accomplishes it.

----- Dave Peterson wrote: -----

start "C:\my documents\excel\book1.xls"

And put your prerecorded macro in a general module and name it Auto_Open.

You could also just create a shortcut to your workbook (on your desktop???) and
then start that, too.


MS-DOS wrote:
Is there a command I can use to launch excel from DOS,

and also have it go right into a pre-recorded macro?
thanks.


--

Dave Peterson



--

Dave Peterson


Russ Robelen[_2_]

need command
 
Many thanks Dave. This is exactly what I was looking for.

----- Dave Peterson wrote: -----

From a previous post:



If you rightclick on the filename when you're in Windows Explorer, you can
select SendTo. There's an option for Desktop (Create shortcut).

This might help if you want VBA:

Option Explicit
Sub CreateShortCut()

Dim myFileName As String

Dim wsh As Object
Dim SC As Object
Dim myPath As String
Dim myLinkName As String

Set wsh = CreateObject("WScript.Shell")

myPath = wsh.SpecialFolders.Item("Desktop")

myLinkName = "mynicelink.lnk"
myFileName = "C:\my documents\excel\book5.xls"

On Error Resume Next
Kill myPath & "\" & myLinkName
On Error GoTo 0

Set SC = wsh.CreateShortCut(myPath & "\" & myLinkName)

SC.TargetPath = myFileName
SC.Save
Set wsh = Nothing

End Sub


Russ Robelen wrote:
Is there a way to create a desktop shortcut to an Excel file programmically in VBA? If so could you direct me to the code snippet that accomplishes it.
----- Dave Peterson wrote: -----
start "C:\my documents\excel\book1.xls"
And put your prerecorded macro in a general module and name it Auto_Open.
You could also just create a shortcut to your workbook (on your desktop???) and

then start that, too.
MS-DOS wrote:
Is there a command I can use to launch excel from DOS,

and also have it go right into a pre-recorded macro?
thanks.
--
Dave Peterson




--

Dave Peterson




All times are GMT +1. The time now is 02:24 PM.

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