Spreadsheet opened by user or programme

  • Thread starter Thread starter Jenni
  • Start date Start date
J

Jenni

Hi, what I'm, wanting to know is if there is a way of knowing if a
spreadsheet was opened by a user clicking on the file name, or if it
was opened by another programme.

something like this:

Private Sub form_activate

If "form was opened by user" then
'do stuff
Else
'form was opened by onother programme - Access in this case
'do other stuff
End if

End Sub

Thanks in advance
Jenni
 
I tried

Select Case TypeName(Application.Caller)
Case "Range"
V = Application.Caller.Address
Case "String"
V = Application.Caller
Case "Error"
V = "Error"
Case Else
V = "unknown"
End Select

MsgBox "caller = " & V

And I get Error irrespective of whether it is called by Access or by me
double clicking on the icon. I also tried to trap the error to get an
error number to use for differentiation, but no luck, it does not give
an error, it just opens.

Any other ideas??

Jenni
 
From help on Application.UserControl

True if the application is visible or if it was created or started by the
user. False if you created or started the application programmatically by
using the CreateObject or GetObject functions, and the application is
hidden. Read/write Boolean.
 
application.caller doesn't provide the information you describe or what was
suggested by PeterS to the best of my knowledge.

As I suggested, look at Application.UserControl
 
Hi,

Application.UserControl gives a value of True irrespective of whether I
start Excel through Access or by double clicking the icon. Perhaps it
makes a difference that I have opened excel using the Shell command from
Access? Here is the code:

retVal = Shell(GetExeFileSpec("Excel.Application") & Space$(1) &
filePath, vbNormalFocus)

and this in the Public Function that passes the value to the shell
command

Case "EXCEL":
Set appObj = CreateObject(strEXEHostClass)
strPath = appObj.Path & "\"
strFileName = "EXCEL.EXE"
strPrompt = "Microsoft Excel"

So it does use the CreateObject function, and the file is hidden. What
am I missing here? Thanks for the help, as I said I am new at this.

Jenni
 
Back
Top