0

I have been trying to find a get around to open a program in excel using VBA to just automatically open instead of having the prompt come up. I am doing this so it will just open my e-mail in the morning. I am on a network and it won't allow me to change anything to the startup other than the manipulation I am using for excel's open files. I have tried using the Shell function in VBA to click the button automatically and tried turning off display alerts. If that doesn't make sense I can try to reword it better, but for now this is the code I have:

Private Sub Workbook_Open()

    ' OrderByDate Macro


     Worksheets("Main Page").Activate


     Application.DisplayAlerts = False



        Range("B4:D20").Select
        ActiveWorkbook.Worksheets("GE Re-Release Website Lookup").Sort.SortFields.Clear
        ActiveWorkbook.Worksheets("GE Re-Release Website Lookup").Sort.SortFields.Add _
          Key:=Range("B5:B20"), SortOn:=xlSortOnValues, Order:=xlAscending, _
          DataOption:=xlSortNormal

      With ActiveWorkbook.Worksheets("GE Re-Release Website Lookup").Sort
         .SetRange Range("B4:D20")
         .Header = xlYes
         .MatchCase = False
         .Orientation = xlTopToBottom
         .SortMethod = xlPinYin
         .Apply
      End With



      Welcome.Show

    Call Shell("C:\Program Files (x86)\Microsoft Office\root\Office16\OUTLOOK.EXE", vbNormalFocus)

      'ActiveWorkbook.FollowHyperlink "C:\Program Files (x86)\Microsoft Office\root\Office16\OUTLOOK.EXE"


End Sub
Stacie
  • 85
  • 10

1 Answers1

1

You don't want ActiveWorkbook.FollowHyperlink, you simply want to Shell() out to launch Outlook.

See this answer on how to set this up.

FreeMan
  • 5,660
  • 1
  • 27
  • 53
  • I was able to do it with the following code: Call Shell("C:\Program Files (x86)\Microsoft Office\root\Office16\OUTLOOK.EXE", vbNormalFocus) – Stacie Sep 28 '18 at 13:31
  • Despite its use in the answers, I don't _think_ `Call` is necessary in this situation. In general, `Call` is deprecated... Glad I was able to help! – FreeMan Sep 28 '18 at 13:41