自动创build文件的快捷方式

我有一个命令button下的一小段代码点击保存在一个新的位置,一个新名称的工作簿文件,我想知道是否有可能也自动创build一个快捷方式到新保存的工作簿在不同的位置?

Private Sub CommandButton1_Click() Dim SelectedFNumber As String Dim DateStr As String Dim myFileName As String Dim StorePath As String DateStr = Format(Now, "dd.mm.yy HH.mm") SelectedFNumber = Range("B4").Text If SelectedFNumber <> "SELECT F NUMBER" And Range("D11") > "0" Then StorePath = "G:\Targets\" & SelectedFNumber & "\" myFileName = StorePath & SelectedFNumber & " " & DateStr & ".xlsm If Len(Dir(StorePath, vbDirectory)) = 0 Then MkDir StorePath End If ActiveWorkbook.SaveAs Filename:=myFileName, FileFormat:=xlOpenXMLWorkbookMacroEnabled Else MsgBox "Select an F Number" End If End Sub 

你基本上需要添加这样的东西:

 Dim sShortcutLocation As String sShortcutLocation = "C:\blah\workbook shortcut.lnk" With CreateObject("WScript.Shell").CreateShortcut(sShortcutLocation) .TargetPath = myFileName .Description = "Shortcut to the file" .Save End With 

将位置更改为您想要的位置。