none
Word 97 VBA wont start in Word 2010 RRS feed

  • Question

  • I have a batch of Word templates that were created in Office 97. And then we upgraded all the way to 2010.

    They mostly seem to run OK, but when we open documents from them they open as .doc in compatability mode, as I'd expect.

    Some start with trying to open a form, triggered by the New or Open methods. In one case this works fine.  But in another, originally created as a copy from the same template, this code doesn't run.  If I run it manually from the Developer tab then it runs OK, but it doesn't trigger automatically as the document opens, or as a new one is created, as it should.  it seems identical to the one that works.

    What do I look for as differences that might explain it?

    Thanks

    Tuesday, October 1, 2013 11:05 AM

Answers

  • Hi Jenni

    Hmmm. In your place, the next thing I'd try would be to use File/Export in the VBA Editor for every code module in the template. This will let you back everything up as plain text files.

    Then I'd save the template as a *.dotx, which will remove the VBA project (and thus any damage connected to it). Close.

    Open the *.dotx again, go to the VBA Editor and use File/Import to bring the code back in. Note that you'll need to copy the content of ThisDocument that you import into the "real" ThisDocument for the file. ThisDocument is a special class which won't be replaced by importing the file, which is why the step is necessary. After you've copied the code over you can delete the imported ThisDocument.

    Save the file now as a *.dotm, close and test.


    Cindy Meister, VSTO/Word MVP, my blog

    Tuesday, October 1, 2013 6:32 PM
    Moderator

All replies

  • Could you please provide more detail about the way the code is constructed so that it should trigger when a document is opened or newly created? It's very difficult to try to trouble-shoot based on such general, vague information...

    One common issue when bringing older documents forward is that they might be damaged in some way that wasn't apparent in the older version, but manifests when the file is opened in a newer one. You might try saving the problem file as a *.dotm to see if that fixes the problem...


    Cindy Meister, VSTO/Word MVP, my blog

    Tuesday, October 1, 2013 3:27 PM
    Moderator
  • Thanks. 

    if I look in the VisualBasic, Under TemplateProject, MicrosoftWord Objects, ThisDocument,  it has VB code:

    Private Sub Document_New()
    frmUpdate.Show
    End Sub

    Private Sub Document_Open()
    frmUpdate.Show
    End Sub

    And in the forms section it has a form frmUpdate

    Same code in both documents and the form was imported from one to the other.

    When we start or open the template or document, the form doesn't appear in one and does appear in the other.

    Behaves the same whether I open the template or the document created from the template, and whether I leave it as .dot, which creates a .doc or save the template as  .dotm and create .docx

    Jenni

    Tuesday, October 1, 2013 3:41 PM
  • Hi Jenni

    Hmmm. In your place, the next thing I'd try would be to use File/Export in the VBA Editor for every code module in the template. This will let you back everything up as plain text files.

    Then I'd save the template as a *.dotx, which will remove the VBA project (and thus any damage connected to it). Close.

    Open the *.dotx again, go to the VBA Editor and use File/Import to bring the code back in. Note that you'll need to copy the content of ThisDocument that you import into the "real" ThisDocument for the file. ThisDocument is a special class which won't be replaced by importing the file, which is why the step is necessary. After you've copied the code over you can delete the imported ThisDocument.

    Save the file now as a *.dotm, close and test.


    Cindy Meister, VSTO/Word MVP, my blog

    Tuesday, October 1, 2013 6:32 PM
    Moderator
  • Yippeee!  Success!

    thanks

    Thursday, October 3, 2013 4:02 PM