need command

  • Thread starter Thread starter MS-DOS
  • Start date Start date
M

MS-DOS

Is there a command I can use to launch excel from DOS,
and also have it go right into a pre-recorded macro?
thanks.
 
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.
 
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
 
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
 
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
 
Back
Top