Results 1 to 2 of 2

Thread: Has anyone done EXTENSIVE Word VBA?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2000
    Posts
    461

    Exclamation

    I'm looking for someone who has done some extensive MS Word VBA code....

    I have come across a problem that occurs when you attempt to save a word document that has a missing reference.

    It reports an error "Disk is Full".

    I have worked that bit out and I have even managed to locate which of the references is missing using the :

    Code:
    ActiveDocument.VBProject.References(x).IsBroken
    But what I need to do now is use VBA to actually REMOVE that missing reference. I know the function that I require, it is :

    Code:
    ActiveDocument.VBProject.References.Remove(<Reference>)
    The problem is that the parameter <Reference> isn't just the item number of the reference I want to remove, the help files say that it is the "reference object" itself.

    Now I have tried evertything from :
    Code:
    ActiveDocument.VBProject.References.Remove(3)
    
    to
    
    ActiveDocument.VBProject.References.Remove(ActiveDocument.VBProject.References(3))
    But it keeps giving me errors.

    If anyone has any idea what the EXACT syntax is for this command could they please give me a hand... it would be muchly appreciated.

  2. #2
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744

    Lightbulb

    You have to pass an object as a paramater. So you can try something like this:
    Code:
        Dim objRef As Object
        Dim i As Integer
        
        
        For i = 1 To ActiveDocument.VBProject.References.Count
            Set objRef = ActiveDocument.VBProject.References(i)
            Debug.Print objRef.Name
            If objRef.IsBroken Then
                ActiveDocument.VBProject.References.Remove objRef
            End If
        Next
    Good luck,

Posting Permissions

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



Click Here to Expand Forum to Full Width