VBA called from Word or Excel or . Function to dDetermin Which

  • Thread starter Thread starter Michael
  • Start date Start date
M

Michael

I have some VBA Code which I am adding to users' Word, Excel or whatever
Tool Bars, which performs a customized SaveAs. I need to know, at this
level, whether it was called from Word or Excel or.....
Does anybody know how this can be done in VBA?

e.g If from Word
ActiveDocument.........saveas....

e.g. if from Excel
ActiveWorkbook........savesas.....



etc
TIA
Michael
 
I have some VBA Code which I am adding to users' Word, Excel or whatever
Tool Bars, which performs a customized SaveAs. I need to know, at this
level, whether it was called from Word or Excel or.....
Does anybody know how this can be done in VBA?

e.g  If from Word
          ActiveDocument.........saveas....

e.g. if from Excel
          ActiveWorkbook........savesas.....

etc
TIA
Michael

The obvious answer is to include the name of the calling app in your
function... just pass it as an argument...
 
Piet, obvious but not what I want.

I want to place the same macro in word/excel... - not slightly different
ones in each.
That's why I need to programmatically find out whether the source is
word/excel/...

Michael


I have some VBA Code which I am adding to users' Word, Excel or whatever
Tool Bars, which performs a customized SaveAs. I need to know, at this
level, whether it was called from Word or Excel or.....
Does anybody know how this can be done in VBA?

e.g If from Word
ActiveDocument.........saveas....

e.g. if from Excel
ActiveWorkbook........savesas.....

etc
TIA
Michael

The obvious answer is to include the name of the calling app in your
function... just pass it as an argument...
 
Michael said:
Piet, obvious but not what I want.

I want to place the same macro in word/excel... - not slightly different
ones in each.
That's why I need to programmatically find out whether the source is
word/excel/...

Michael




The obvious answer is to include the name of the calling app in your
function... just pass it as an argument...

Try using Application.Name. Returns "Microsoft Access" for Access,
"Microsoft Excel" for Excel and "Microsoft Word" for Word.
 
Thanks Stuart that worked. I'm placing another post which you may know an
answer for for.

Michael
 
Back
Top