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

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
 
P

Piet Linden

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...
 
M

Michael

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...
 
S

Stuart McCall

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.
 
M

Michael

Thanks Stuart that worked. I'm placing another post which you may know an
answer for for.

Michael
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top