ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   macro names not consistent? (https://www.excelbanter.com/excel-programming/312355-macro-names-not-consistent.html)

alex999

macro names not consistent?
 

Hi,

I have a subroutine written, to be run on various different machines.
This is to be run automatically as part of an overnight procedure, so
have it being called from a VBscript file. Of the form


Code
-------------------
Set xlObj = CreateObject("Excel.application")
xlObj.Workbooks.Open "c:\trinity\exchange.xls"
xlObj.Run "ExchangePriceImport"
xlObj.ActiveWorkbook.Saved = True
xlObj.ActiveWindow.Close
xlObj.Qui
-------------------


However, on certain machines this code fails, saying the macro canno
be found.
On looking in the workbook under toolsmacros, the name seems to be o
the form

exchange.xls!sheet1.ExchangePriceImport

However on other machines, opening the file shows the macro in the lis
as ExchangePriceImport only.

What is casuing this, and how can I stop the name being altered? a
this is stopping processes runing on certain systems.

Excel version is 2000 and they're all running the same service pack.

Thank

--
alex99
-----------------------------------------------------------------------
alex999's Profile: http://www.excelforum.com/member.php...fo&userid=1497
View this thread: http://www.excelforum.com/showthread.php?threadid=26602


keepITcool

macro names not consistent?
 
there is a significant difference between placing the macro in a sheet's
code module or placing it in a normal code module.

imho: code that is NOT strictly related to events or controls should never
be placed in an object module.

SO I suggest that you check your files, and for those files where the
macro shows up as sheet1.MyMacro you'll have to move the procedure to
a normal module.

moreover...
if the code in all those files is the same...
adapt your code to work independent of the specific files
(either make it work with a workbook variable or with the activeworkbook)
remove the macro's from your workbooks and include the adapted procedure
in your vbs script/file.

moreover...
if all your users use the same file anyway...
(exchange rates suggest a readonly scenario)
....
why not store it in 1 networklocation, mark it as readonly,
and have the users share it?

(be sure to remove the readonly attribute in your update script :)





keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool


alex999 wrote:


Hi,

I have a subroutine written, to be run on various different machines.
This is to be run automatically as part of an overnight procedure, so I
have it being called from a VBscript file. Of the form


Code:
--------------------
Set xlObj = CreateObject("Excel.application")
xlObj.Workbooks.Open "c:\trinity\exchange.xls"
xlObj.Run "ExchangePriceImport"
xlObj.ActiveWorkbook.Saved = True
xlObj.ActiveWindow.Close
xlObj.Quit
--------------------


However, on certain machines this code fails, saying the macro cannot
be found.
On looking in the workbook under toolsmacros, the name seems to be of
the form

exchange.xls!sheet1.ExchangePriceImport

However on other machines, opening the file shows the macro in the list
as ExchangePriceImport only.

What is casuing this, and how can I stop the name being altered? as
this is stopping processes runing on certain systems.

Excel version is 2000 and they're all running the same service pack.

Thanks





All times are GMT +1. The time now is 12:01 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com