I'm building an application that calls applications like Microsoft Word, Microsoft Excel and so.
When I call Microsoft Word in my aplication I code:
==========================================================
Dim appword As Word.Application
' Aquest missatge s'encarrega de carregar el Word
On Error Resume Next 'ignora els errors produits
' Comprova si hi ha alguna còpia de word en execució
Set appword = GetObject(, "Word.Application"
' Si no hi ha cap còpia en execució arranca una execució nova
If Err.Number <> 0 Then
Set appword = CreateObject("Word.Application"
End If
' inicialitza la variable d'errors
Err.Clear
' Mostra el word
appword.Visible = True
appword.WindowState = wdWindowStateMaximize
On Error GoTo 0
=========================================================
The previous code opens Microsoft Word only if it is not running. After it makes Microsoft Word visible and maximizes it.
I use the same code to open Microsoft Excel. In this case I look that Excel opens and inmediately closes, Microsoft word remains open.
The code for the case of Microsoft Excel is:
==========================================================
Dim appexcel As Excel.Application
' Aquest missatge s'encarrega de carregar el Excel
On Error Resume Next 'ignora els errors produits
' Comprova si hi ha alguna còpia de word en execució
Set appexcel = GetObject(, "Excel.Application"
' Si no hi ha cap còpia en execució arranca una execució nova
If Err.Number <> 0 Then
Set appexcel = CreateObject("Excel.Application"
End If
' inicialitza la variable d'errors
Err.Clear
' Mostra el word
appexcel.Visible = True
appexcel.WindowState = xlMaximized
On Error GoTo 0
=========================================================
What can I do if I want that Microsoft Excel remains open after the previous code?
Thanks
PD: Sorry for my english
[sig][/sig]
When I call Microsoft Word in my aplication I code:
==========================================================
Dim appword As Word.Application
' Aquest missatge s'encarrega de carregar el Word
On Error Resume Next 'ignora els errors produits
' Comprova si hi ha alguna còpia de word en execució
Set appword = GetObject(, "Word.Application"
' Si no hi ha cap còpia en execució arranca una execució nova
If Err.Number <> 0 Then
Set appword = CreateObject("Word.Application"
End If
' inicialitza la variable d'errors
Err.Clear
' Mostra el word
appword.Visible = True
appword.WindowState = wdWindowStateMaximize
On Error GoTo 0
=========================================================
The previous code opens Microsoft Word only if it is not running. After it makes Microsoft Word visible and maximizes it.
I use the same code to open Microsoft Excel. In this case I look that Excel opens and inmediately closes, Microsoft word remains open.
The code for the case of Microsoft Excel is:
==========================================================
Dim appexcel As Excel.Application
' Aquest missatge s'encarrega de carregar el Excel
On Error Resume Next 'ignora els errors produits
' Comprova si hi ha alguna còpia de word en execució
Set appexcel = GetObject(, "Excel.Application"
' Si no hi ha cap còpia en execució arranca una execució nova
If Err.Number <> 0 Then
Set appexcel = CreateObject("Excel.Application"
End If
' inicialitza la variable d'errors
Err.Clear
' Mostra el word
appexcel.Visible = True
appexcel.WindowState = xlMaximized
On Error GoTo 0
=========================================================
What can I do if I want that Microsoft Excel remains open after the previous code?
Thanks
PD: Sorry for my english
[sig][/sig]