VBA code not deleting macros

D

Doug Barnes

I think I have a comparable problem to "Howard Kaikow"
I'm using an "autoexec" macro to check & update a suite of
macros if a later version exists
Most of the code is OK, but I repeatedly find that a
couple of modules won't delete, and if I can't delete
them I can't copy the new version across

Simplified routine is (excuse any layout errors)
For all "macros & forms"
if new version > old version then
call DELMACRO(macroname)
end if
call addnewversion
Next "macro & forms"

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 they then won't add. 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 using the VBA project window,
but can't see how that can be applied in normal VBA code
execution.

Once the program's crashed on the copy (can't copy over
existing file) they've 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 when I exit Word.
When I restart work 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

Any ideas on either issue??
 
H

Howard Kaikow

The problem with toolbars is not related to any problem with code.

Looking at the pseudo-code below, I note that you are deleting "if new
version > old version" but there is no way to programmatically determine the
date/time a module was created (I sure wish there were a way).

In order to replace a module, you must first delete the old version.
 
D

Doug BArnes

I admit the code was VERY simplified, I actually track
the installed version in the registry and compare to a
tracking file on the server which holds the latest
versuion number.
I was comparing the fact that the "application.delete"
doesn't work as it should or is claimed to, in my case
for macros, in your case for toolbars
 
H

Howard Kaikow

There is no comparison between the deletion of toolbars and macros.
They are very different issues.
 

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