View Single Post
  #12   Report Post  
Posted to microsoft.public.excel.programming
ina ina is offline
external usenet poster
 
Posts: 120
Default Workbook_open - Sub problem

yes thanks I have an error as the Object variable is not set.


Tom Ogilvy wrote:
if all your code is in the Thisworkbook module:

Dim oExec As Object

Public Sub Workbook_Open()
' ************
' Variables
' ************
Dim dtmTime As Date
Dim dtmSave As Date



' ************
' Call function OpenPHObject
' ************
Set oExec = OpenPHObject()

' ************
' Cursor in clock shape
' ************
Application.Cursor = xlWait
DoEvents

On Error Resume Next
' ************
' After seven seconds the macros has been launched
' ************
dtmTime = Now + TimeValue("00:00:07")
' ************
' Open the sub in thisworkbook
' ************
Application.OnTime dtmTime, "thisworkbook.operations"
Application.Cursor = xlDefault
Application.DisplayAlerts = False
'Sheets(Array("Read Me", "File Layout", "Index", "Quotes")).Copy
ActiveWorkbook.SaveAs Filename:= _
"C:\tet_1.xls", fileformat:= xlNormal, ReadOnlyRecommended:=False,
CreateBackup:=False

Application.DisplayAlerts = True
' ************
' Now + 7seconds + 30 seconds -- launch SAVEandEXIT and close PH
(external program)
' ************
dtmSave = dtmTime + TimeValue("00:00:30")

Application.OnTime dtmSave, "thisworkBook.Save_Exit"
' I have a problem here
' because it is not recognize the Save_Exit Sub



End Sub



Public Sub Operations()

Sheet3.Activate
Sheet3.ExecGetInfo
Sheet4.Activate
Sheet4.ExecGetExtra

End Sub

Public Sub Save_Exit()

Call ClosePHObject(oExec)
SaveAsWithoutCode 'delete all macro
Application.Quit
ThisWorkbook.Close SaveChanges:=True
End Sub

--
Regards,
Tom Ogilvy


"ina" wrote:

But my variable oExec coming from my function Set oExec =
OpenPHObject()

can I do it?

Ina