Consulting

Results 1 to 3 of 3

Thread: Solved: Odd file open behaviour with RibbonX

  1. #1
    VBAX Regular
    Joined
    Mar 2009
    Location
    123° 21´ 56´´ W, 48° 28´ 23´´ N
    Posts
    11
    Location

    Solved: Odd file open behaviour with RibbonX

    I'm in the process of migrating a slew of Office 2003 code to Office 2007, and will have to move a lot of commandbar functionality to custom tabs, groups, etc. My only tools will be VBA and the Custom UI Editor/XML Notepad pair.

    Anyway, my immediate problem is that when my callback runs code to add a new document to the Documents collection with a specific template, Word reports the file is corrupt and throws error 5151 (corrupt file). If I open the file 'manually' with File->Open, the contents and macros in it appear to be healthy. Does this sound familiar to anyone? I've tried the Open and Repair method in Word, but it has no apparent effect; the error continues. Any clues on this would, of course, be greatly appreciated.

    The XML is embedded in a global template loaded at startup. The callback is in a module named 'modRibbon' and it calls a Sub in another module in the same project named 'modMain. The Sub itself contains a single line, and this is where the error is thrown:

    [VBA]
    Documents.Add Options.DefaultFilePath(wdUserTemplatesPath) & Application.PathSeparator & "Referral Packager.dotm"[/VBA]

    Backing up a bit, here is the RibbonX for my button:

            <button id="btnReferral" label="Package Referrals" imageMso="MailMergeMergeToDocument"
              onAction="modRibbon.button_onAction" />
    . . . and the button_onAction callback itself:

    [VBA]
    Sub button_onAction(ByVal control As IRibbonControl)

    Select Case control.ID
    . . .
    Case Is = "btnReferral"
    modMain.MakeReferralPackages
    . . .
    Case Else
    'Do nothing
    End Select
    End Sub 'button_onAction
    [/VBA]

    Thanks for your time,
    Terry

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    This now says solved. Can you share the solution with us?
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Regular
    Joined
    Mar 2009
    Location
    123° 21´ 56´´ W, 48° 28´ 23´´ N
    Posts
    11
    Location
    The "solution" is to not rename templates so that your code is looking for a file that no longer exists.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •