What does a File open like this Q

S

Sean

I have a file that when opened (I normally open via Windows Explorer)
reverts the screen via back to Windows Explorer. Why is that?

I have tried to place the Sheet name within the code that I want it to
start the view from (front Page), but it makes no difference



Option Explicit
Sub Auto_Open()

Application.ScreenUpdating = False
Application.WindowState = xlMinimized

Dim OLKApp As Outlook.Application
Dim WeStartedIt As Boolean


On Error Resume Next
Set OLKApp = GetObject(, "Outlook.Application")
On Error GoTo 0
If OLKApp Is Nothing Then
Set OLKApp = CreateObject("Outlook.Application")
If OLKApp Is Nothing Then
' can't create app
' error mesage then exit
MsgBox "Can't Get Outlook"
Exit Sub
End If
WeStartedIt = True
Else
WeStartedIt = False
End If

Sheets("Front Page").Activate
Range("A1").Select


Dim OkToCallMacro As Boolean
OkToCallMacro = False
Select Case Weekday(Date)
Case vbMonday To vbFriday
If Time >= TimeSerial(8, 44, 0) _
And Time < TimeSerial(8, 46, 0) Then
OkToCallMacro = True
End If
Case Is = vbSaturday, vbSunday
If Time >= TimeSerial(8, 44, 0) _
And Time < TimeSerial(8, 46, 0) Then
OkToCallMacro = True
End If
End Select

If OkToCallMacro Then
Call Copy_Paste

If Workbooks.Count = 1 Then
'only this workbook is open
ThisWorkbook.Save
'close the application
'(which will close thisworkbook)
Application.Quit
Else
ThisWorkbook.Close savechanges:=True
End If
End If

If WeStartedIt = True Then
OLKApp.Quit

End If
End Sub
 
D

Doug Glancy

Sean,

Your second line:

Application.WindowState = xlMinimized

means that Excel is minimized. This means that you see Windows Explorer,
since it was the last program you were in.

hth,

Doug
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top