ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Programmatically detecting presence of named macro in workbook (https://www.excelbanter.com/excel-programming/371227-programmatically-detecting-presence-named-macro-workbook.html)

SteveS[_6_]

Programmatically detecting presence of named macro in workbook
 
I have a client with a number of workbooks, which were generated from a
template. The template has been through a number of revisions. For
simplicity's sake, v1 did not have a given macro XXXX in, v2 did, and v3 (and
subsequent versions) did not.

Is there a way to identify whether a given workbook contains the macro XXXX
(but without running the macro) programmatically, so that those workbooks can
be backed up, and manually modified?

The presence of the macro actually tells us that some other VBA code in the
document is incorrect and will need updating, nothing more sinister, and
while I am familiar with 'standard' VBA stuff and automation in general (I
also design and code in C++, including COM servers and clients), I know
little about the internal structure of workbooks (since I've never needed to,
that's what automation is for...), so I'd appreciate any pointers. I
estimate that in total there are around 4500 documents to check, and
unfortunately, most have been updated on a regular basis, so datestamps don't
help (although some can be eliminated by creation time).

Thanks in advance
--
Steve S

Tom Ogilvy

Programmatically detecting presence of named macro in workbook
 
You can get a head start at Chip Pearson's site
http://www.cpearson.com/excel/vbe.htm

--
Regards,
Tom Ogilvy


"SteveS" wrote:

I have a client with a number of workbooks, which were generated from a
template. The template has been through a number of revisions. For
simplicity's sake, v1 did not have a given macro XXXX in, v2 did, and v3 (and
subsequent versions) did not.

Is there a way to identify whether a given workbook contains the macro XXXX
(but without running the macro) programmatically, so that those workbooks can
be backed up, and manually modified?

The presence of the macro actually tells us that some other VBA code in the
document is incorrect and will need updating, nothing more sinister, and
while I am familiar with 'standard' VBA stuff and automation in general (I
also design and code in C++, including COM servers and clients), I know
little about the internal structure of workbooks (since I've never needed to,
that's what automation is for...), so I'd appreciate any pointers. I
estimate that in total there are around 4500 documents to check, and
unfortunately, most have been updated on a regular basis, so datestamps don't
help (although some can be eliminated by creation time).

Thanks in advance
--
Steve S


SteveS[_6_]

Programmatically detecting presence of named macro in workbook
 
"Tom Ogilvy" wrote:

You can get a head start at Chip Pearson's site
http://www.cpearson.com/excel/vbe.htm


Thanks, Tom, that's just the thing. I've 'converted' the relevant bits to a
C++ app that queries the GIT to make sure office apps aren't running, tweaks
the registry while it loads up excel, does it's stuff, then restores the
security settings, and it seems to be working !

Steve S

Peter Huang [MSFT]

Programmatically detecting presence of named macro in workbook
 
Hi Steve,

Thanks for your knowledage sharing and Tom's contribution in the community.

Anyway if you still have any concern about this issue, please feel free to
let me know and I am happy to be of assistance.

Thanks!

Best regards,

Peter Huang

Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.


NickHK

Programmatically detecting presence of named macro in workbook
 
Steve,
Just looking at a workbook in a text editor, I can see the name of a custom
function.
As long as the routine names are unique, a scan of the text would show up.

NickHK

"SteveS" wrote in message
...
I have a client with a number of workbooks, which were generated from a
template. The template has been through a number of revisions. For
simplicity's sake, v1 did not have a given macro XXXX in, v2 did, and v3

(and
subsequent versions) did not.

Is there a way to identify whether a given workbook contains the macro

XXXX
(but without running the macro) programmatically, so that those workbooks

can
be backed up, and manually modified?

The presence of the macro actually tells us that some other VBA code in

the
document is incorrect and will need updating, nothing more sinister, and
while I am familiar with 'standard' VBA stuff and automation in general (I
also design and code in C++, including COM servers and clients), I know
little about the internal structure of workbooks (since I've never needed

to,
that's what automation is for...), so I'd appreciate any pointers. I
estimate that in total there are around 4500 documents to check, and
unfortunately, most have been updated on a regular basis, so datestamps

don't
help (although some can be eliminated by creation time).

Thanks in advance
--
Steve S




SteveS[_6_]

Programmatically detecting presence of named macro in workbook
 
"NickHK" wrote:

Steve,
Just looking at a workbook in a text editor, I can see the name of a custom
function.
As long as the routine names are unique, a scan of the text would show up.

NickHK


Thanks. I'd looked at that but rejected it, as I need to be more accurate
than that really. As it turns out, the advice given by Tom enables me to
perform the whole job. I run a scan of the XLS files first, and back them up,
and then apply the edits, so I'm quite pleased with that; I just send my
client an EXE and it's all done as far as they are concerned.
I really need to spend less time with a C++ development system and more
examining the Office stuff!


Steve S


All times are GMT +1. The time now is 01:15 PM.

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