Re: GRAHAM MAYOR - Re: Macro in Normal.dot prevents Word opening

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Start Word in its safe mode by holding the CTRL key as you start it. Does it
work now? If it does then you still have some external problem - look again
at the printer driver on your PC.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

Fern wrote:
Ooops, looks like I spoke too soon. Despite removing both add-ins
from their start-up folders, and only using one archiving macro at a
time, Word still crashes whenever it's opened. Don't know why it
worked that one time...
And fyi, other than the nearly-identical AutoClose & manual archiving
macros, I haven't added to or changed the default Normal.dot template.

So I guess the search continues... Sigh.




"Fern" wrote:

LOOKS LIKE WE MIGHT HAVE A SOLUTION!!!

Settings file: check!
Printer driver: already dealt with - I'm on a network and so that
problem came up a couple weeks ago...
Temps cleared: check!
Add-ins: I removed both of my add-ins (RefWorks & MathType), saved
AutoClose to Normal.dot, closed the program, and tried to re-open
it.... AND IT WORKED!! YIPPEEE! I've got to test it a few more times
& ways jsut to be sure, but it looks like we've got a winner!!

THANK YOU SO MUCH GRAHAM! You've been a HUGE help. I'm really
grateful!! :-D


"Graham Mayor" wrote:

I would be inclined to use a settings file to hold the data rather
than the registry (you'll find out how to do that from my web site
- eg http://www.gmayor.com/automatic_numbering_documents.htm), but
I don't see why an autoclose macro should have any effect on
*starting* Word. The macro doesn't run until you *close* a
document. I would be more interested in autoopen/autonew/autoexec
macros and the content of any add-ins.

Don't forget to clear the temps after a crash and it might be worth
repairing Word.

A defective printer driver can be a cause of hard-to-identify
crashes. Try updating/reinstalling the driver.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

Fern wrote:
Wow! That actually worked! I'm shocked!! THANKS GRAHAM!

I guess I'd misunderstood your website's explanation (about
changing .dot to .old) and just figured that was just a random
example of how to rename the template file so it wouldn't
automatically kick in as Normal.dot when Word opened.

Anyway... This is EXCELLENT. Not only do I have access to the
macros again but I also know that the problem is somewhere in the
coding itself because Word crashes when I try to open it after
moving the 3 macros from Normal.old into Normal.dot. Hmm, I wonder
what the snag is. I just took a quick peek at the codes and they
SEEMED fine. But clearly something is still wrong.

So here's what's odd: (1) when I tried to open Word with all 3
macros in the new Normal.dot it crashed, (2) when I tried to open
it with only 1 macro at a time in Normal.dot it crashed, BUT (3)
when I copied those 1-3 macros to a different template file
(NotNormal.dot) & then tried to open Word by opening a document
formatted with NotNormal.dot, Word opened perfectly. So what does
that tell us?? I haven't a clue. I guess there's something in one
or all of the codes (& that wasn't there in the 2nd template that
worked all along) that really doesn't work well with the built in
processes of Normal.dot. Hmm.

The same problem is happening when I try to open my current
attempt at writing an archiving code. It works great in any other
template, but crashes the program when I put it into Normal.
Could some good samaritan look at the code and tell me which part
is incompatible with Normal.dot?? The following is the AutoClose
routine from my most recent attempt at this archiving macro. It's
supposed to check whether the open doc is 'flagged' for archiving
and, if it is, to copy it to an archive folder. I've got a
separate subroutine that can be called from the toolbar and that's
used to 'flag' the open doc & archive an instant 'snapshot' of the
file without having to wait until the doc is closed. Ok, so here's
the code (& yes I know it's wordy but I like it to be intuitively
readable even months after it's written):
________________________________________________________-- Sub
AutoClose() '
Dim WSHShell, RegKey, rkeyWord, Result
Set WSHShell = CreateObject("WScript.Shell")
Dim TodaysDate As String, OldVersionPath As String,
OldVersionFile As String, OldVersionName As String
Dim NewVersionFile As String, intPos As Integer, DirExists As
Boolean, OldVersionFileNPath As String
Dim NewVersionPath As String, NewVersionFileNPath As String,
fso, MyRecentFile As RecentFile
Dim FirstTimeArchiving As Boolean
Set fso = CreateObject("Scripting.FileSystemObject")

On Error GoTo CancelledByUser
ActiveDocument.Save

FirstTimeArchiving = False
OldVersionFile = ActiveDocument.Name 'Get document name
OldVersionName = Left(OldVersionFile, Len(OldVersionFile) - 4)
'remove the file extention

Start:
RegKey =
"HKEY_CURRENT_USER\Software\Microsoft\Office\Word\Settings\" On
Error Resume Next 'No entry in registry will flag an error
rkeyWord = WSHShell.RegRead(RegKey & OldVersionName) If
rkeyWord = "" Then 'If the registry entry doesn't exist (i.e.
the
file hasn't been flagged to be archived)
GoTo StopCode
Else 'if it HAS been set for archiving...
On Error GoTo CancelledByUser
OldVersionPath = ActiveDocument.Path 'Get path
OldVersionFileNPath = OldVersionPath & "\" & OldVersionFile
'Get document's full name & path
NewVersionPath = "C:\Documents and Settings\{USER}\Word
Archive\Archived '" & OldVersionName & "'"
'Checks if an archive folder exists &, if not, makes one
If Not fso.FolderExists(NewVersionPath) Then
fso.CreateFolder (NewVersionPath)
End If
'Define the new version's filename
TodaysDate = Format((Date), "yyyy-mm-dd")
NewVersionFile = OldVersionName & " (" & TodaysDate &
").doc" NewVersionFileNPath = NewVersionPath & "\" &
NewVersionFile 'copy the current/active document to the
archive location &
file
name (without adding it to the 'Recent Files' list)
WordBasic.CopyFileA FileName:=OldVersionFileNPath,
Directory:=NewVersionFileNPath
If FirstTimeArchiving = True Then
MsgBox "The current version of this document has been
archived. It will now be archived whenever it's closed."
End If
End If
GoTo StopCode

CancelledByUser: 'Trap the pressing of the Cancel button
MsgBox "There was a problem running the code & this file version
wasn't archived.", , "Archiving Cancelled"
GoTo StopCode
StopCode:
End Sub
_________________________________________________-
So can you what might be messing with my code when it's put in
Normal.dot?

Thanks for all of your help so far!! You guys have been great,
especially you Graham!!


.



Relevant Pages

  • Re: GRAHAM MAYOR - Re: Macro in Normal.dot prevents Word opening
    ... autoopen/autonew/autoexec macros and the content of any add-ins. ... from my most recent attempt at this archiving macro. ... Dim TodaysDate As String, OldVersionPath As String, OldVersionFile ... As String, OldVersionName As String ...
    (microsoft.public.word.vba.general)
  • Re: GRAHAM MAYOR - Re: Macro in Normal.dot prevents Word opening
    ... autoopen/autonew/autoexec macros and the content of any add-ins. ... from my most recent attempt at this archiving macro. ... Dim TodaysDate As String, OldVersionPath As String, OldVersionFile ... As String, OldVersionName As String ...
    (microsoft.public.word.vba.general)
  • Re: GRAHAM MAYOR - Re: Macro in Normal.dot prevents Word opening
    ... other than the nearly-identical AutoClose & manual archiving ... macros, I haven't added to or changed the default Normal.dot template. ... A defective printer driver can be a cause of hard-to-identify crashes. ... As String, OldVersionName As String ...
    (microsoft.public.word.vba.general)
  • Re: GRAHAM MAYOR - Re: Macro in Normal.dot prevents Word opening
    ... Word crashes when I try to open it after moving the 3 macros from Normal.old ... most recent attempt at this archiving macro. ... Dim TodaysDate As String, OldVersionPath As String, OldVersionFile As ...
    (microsoft.public.word.vba.general)
  • RE: Macro in Normal.dot prevents Word from opening or debugging!
    ... If you think its your code, disable the Macros in your security settings. ... into my Normal.dot template & added some lines to check whether a given file ... had had archiving enabled - if not, the file SHOULD have opened & closed as ... Dim iCount As Integer, StrDate As String, StrPath As String, StrFile As ...
    (microsoft.public.word.vba.general)