PDA

View Full Version : Macro for Word and Excel



ericc
10-13-2008, 08:04 AM
Hi

I try to write a macro to be used as an add-in in Excel and in Word.
Because I am lazy, I dreamed to have the same macro/add-in for both application.
How innocent I am !! :doh:

Of course the VBA from Excel, isn't the same as the VBA from Word! :(
How it could be, they don't come from the same company and aren't "integrated" in the same umbrella as OpenOffice (ironic mode, sorry).

I try to do a real simple thing. As my colleague use a lot of different regional setting, I try to read the "ListSeparator":
in Excel:
strListSep = Application.International(xlListSeparator) in Word:
strListSep = Application.International(wdListSeparator) Of course, the index of the parameter is not the same !!! :banghead:

Now my question:
Is it possible from the macro to detect from which application (Word or Excel) the macro was launched ?

Any help will be really appreciate

Best regards

ericc

Bob Phillips
10-13-2008, 08:15 AM
Of course the VBA from Excel, isn't the same as the VBA from Word! :(
How it could be, they don't come from the same company and aren't "integrated" in the same umbrella as OpenOffice (ironic mode, sorry).

that is sarcasm, maybe be able to call it satire, but certainly not irony.



strListSep = Application.International(xlListSeparator) in Word:
strListSep = Application.International(wdListSeparator) Of course, the index of the parameter is not the same !!! :banghead:

The products once were independent, stand-alone products, before Office was a glimmer in some MS marketeer's eyes, so they developed independently. Happens all the time.



Now my question:
Is it possible from the macro to detect from which application (Word or Excel) the macro was launched ?

Watch closely, this is tricky


?Application.Name

ericc
10-13-2008, 08:16 AM
Ok sorry, I reply to myself :whistle:
It was simple !!
strAppli = Application
works in both Excel and Word and give the name of the application ...

ericc

ericc
10-13-2008, 08:21 AM
that is sarcasm, maybe be able to call it satire, but certainly not irony.
Yes, you right. I was unable to find the correct word. (I am not English !)



The products once were independent, stand-alone products, before Office was a glimmer in some MS marketeer's eyes, so they developed independently. Happens all the time.
I know the story, but I hope since the years that they had reach a better level of integration... It's really frustrating sometime



Watch closely, this is tricky


?Application.Name

I found it in the mean time, thanks anyway

ericc

Bob Phillips
10-13-2008, 08:30 AM
Yes, you right. I was unable to find the correct word. (I am not English !)

I see that, Eric seems to be a popular name in Belgium.



I know the story, but I hope since the years that they had reach a better level of integration... It's really frustrating sometime

The problem as always is backward compatibility. If they change it to make it more integrated, loads of working solutions will suddenly break.

MS have been very good at backward compatibility in the past, but with XL 2007 they have been less good than usual, and got a lot of flak for it. I am not one to defend MS, their army of lawyers are far better at it than me, but they really cannot win with this one.