Macro Deleter, second request

D

Doug Barnes

I'm using an "autoexec" macro to check & update members of
a suite of macros if a later version exists
Most of the code is OK and I can ALWAYS delete 10 out of
the 12 macros with no problems , but I repeatedly find
that a couple of modules won't delete
If I can't delete them I can't copy the new version across
There's no point in writing all the code, so Simplifying
the core update routine

For all "macros & forms" '(this works OK)
if new version > old version '(I can identify if the
macro is uptodate very reliably)
then call DELMACRO(macroname)
call addnewversion(macroname) ' (this works I've
no problems with it)
end if
Next "macro & forms"
' this is the sub that dosn't ALWAYS work
Sub DelMacro(ThisMacro)
Application.OrganizerDelete _
Source:=NormalTemplate.fullname _
, Name:=ThisMacro _
, Object:=wdOrganizerObjectProjectItems
End Sub
Most of the time it works, but for two macros called "Get
WorkingDirectoryCode" & "GetPrinterModelCode", it won't
delete them, so then I cant copy the new version across.
I've tried a different name (GWDC & GPMC) but that doesn't
make any difference
I've even tried capitalising the names just in case there
was a case (capital vv lower) issue involved like in some
library code, but that doesn't make any difference
I can always delete them manually using the VBA project
window, but can't see how I can program that into normal
VBA code execution.
Once the program's crashed on the following copy attempt
(it can't copy over existing file) the program I had tried
to delete HAS GONE gone from the project list, but then
it's a bit late.
Secondly, I've just moved up to Office 2K3 and find that
changes to the Autoexec macro don't always seen to be
saved (despite clicking the Save ICON) once I exit Word.
When I restart Word sometimes an earlier version of the
Autoexec macro runs and it's becoming rather frustrating
to troubleshoot the Macrodelete problem when you find the
latest code you're trying has disappeared
Has anyone else seen this, Any ideas on either issue??
 
R

Robin Tucker

Just a thought, might be totally unrelated, but you are deleting items from
the collection you are iterating? This could be a problem. ie. if you are
iterating from 1..n, and you delete an item, then "next n" isn't the item
after the item you have deleted, its the item after the item after the item
you deleted. I hope that made sense. On the other hand, this may not be
the problem at all :)
 

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