ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   What does a File open like this Q (https://www.excelbanter.com/excel-programming/399473-what-does-file-open-like-q.html)

Sean

What does a File open like this Q
 
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


Doug Glancy[_8_]

What does a File open like this Q
 
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

"Sean" wrote in message
ps.com...
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



Sean

What does a File open like this Q
 
Of course! Thanks Doug






All times are GMT +1. The time now is 01:06 AM.

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