Results 1 to 6 of 6

Thread: How to check incorrect project references in Visual Basic Editor in Word?

  1. #1
    Join Date
    May 2009
    Posts
    258

    How to check incorrect project references in Visual Basic Editor in Word?

    Hi friends,
    I am having the basic knowledge of programming like VB and VBA. I want to know how to create the references to other Microsoft Visual Basic for Applications (VBA) projects. Also I want to know that the references are correct and how to programmatically remove incorrect references.?? Hope that you got the point that I want to ask.?! So please explain me how to check incorrect project references in Visual Basic Editor in Word? Help me as early as possible.!!

  2. #2
    Join Date
    Jul 2006
    Posts
    339

    Re: How to check incorrect project references in Visual Basic Editor in Word?

    In Microsoft Word Visual Basic Editor, you can create references to object libraries or code in an external document or template. This will be able to call external procedures as if they were written in your own project. Note that problems can occur if the referenced files are moved or damaged. Macro storage errors can occur and the References dialog box can become inaccessible. The following steps would be useful for Setting security permissions Project :
    1. In Microsoft Word, on the Tools menu, point to Macro and click Security to display the dialog security.
    2. On the Security Level tab, set the security level to medium, so that you have the choice to activate your macro.
    3. On the Trusted Sources tab, check the box Trust in Visual Basic is selected. This allows to use VBA code in your projects.
    4. Click OK.

  3. #3
    Join Date
    Aug 2006
    Posts
    222

    Re: How to Create Project Reference in Visual Basic Editor in Word?

    First you should know how to create a reference model Refme as follows :
    1. In the Tools menu, click References.
    2. In the References dialog box, click Browse.
    3. In the dialog Add Reference, set file type to Word documents (. * Doc *. Dowry).
    4. In the file "C: \ testfiles", select the model Refme.
    5. Click Open to return to the References dialog box.
    6. Click OK to return to Visual Basic Editor.

    Then follow the steps to create the reference :
    1. In Word, create a new document and then save it as Myproj.doc in the folder C: \ testfiles.
    2. Start Visual Basic Editor (ALT + F11). In the Project Explorer, select Project (MyProj).
    3. Then create a reference model Refme as mentioned above.
    4. In the Project Explorer, expand the project (MyProj). Developing benchmarks and verify that the reference list includes references Refme.dot.
    5. On the Insert menu, click Module to insert a new module in the project. Write the following code in the module to call the procedure CallMe :
      Code:
      Public Sub Test ()
         Call CallMe
      End Sub
    6. Test procedure to verify that it works and then return to Word.
    7. Save and close the document file and then quit Word.
    Just a reply to say thank you for these links and posts I have a lot to read and learn now!



  4. #4
    Join Date
    May 2008
    Posts
    353

    Re: How to check incorrect project references in Visual Basic Editor in Word?

    To break the reference, the following steps would be useful for you :
    1. In Windows Explorer, change the model name Refme.dot "Refme.old". To do this, click the right mouse button on Refme.dot and then click Rename on the shortcut menu. Refme.old type, then press ENTER.
    2. Back in Word and reopen the document "Myproj.doc.
    3. Because the security level is set to Medium, you will be asked if you want to enable or disable macros in this document. Click Enable Macros.
    4. Start Visual Basic Editor (ALT + F11), then run the test procedure. Click OK to the message following compilation error :
      Project or library not found
    5. You must be in pause mode (there is a yellow band on the Sub line). In the run menu, click Reset to return to Design view.
    6. In the Tools menu, click References to display the References dialog box. You see that Refme.dot is marked as "missing".
    7. Click Cancel to close the References dialog box.

  5. #5
    Join Date
    Apr 2008
    Posts
    2,139

    Re: How to check incorrect project references in Visual Basic Editor in Word?

    If you want to check the missing references programmatically, you can follow the mentioned steps :
    1. In the Project Explorer, select Project (MyProj).
    2. In the Tools menu, click References, and add a reference to Microsoft Visual Basic for Applications Extensibility 5.3 library. This library contains objects that show the VBA projects.
    3. Before clicking OK, you should check that the new reference is added above the reference "missing". Click on the arrow repeatedly to change the priority, move the new reference above the reference "missing", then click OK.
    4. In the module, create a sub procedure named "CheckReference", then write the following code :
      Code:
      Sub CheckReference ()
      
          Sun vbproj As VBProject 'This refers to your VBA project.
          Sun chkRef As Reference 'A reference.
        
          'Refer to the ActiveDocument's VBA project.
          Set vbproj = ActiveDocument.VBProject
      
          'Check through the selected references in the References dialog box.
          For Each chkRef In vbProj.References
        
             'If the reference is broken, send the name to the Immediate Window.
             Then if chkRef.IsBroken
                Debug.Print chkRef.Name
             End If
      
          Next
      
       End Sub
    5. In the View menu, click Immediate Window (CTRL + G) to open the window.
    6. Run the CheckReference sub procedure. The name and location of the file appears in the window.

  6. #6
    Join Date
    May 2008
    Posts
    4,831

    Re: How to delete references in Visual Basic Editor in Word?

    I am providing you the steps that can be useful for deleting a missing reference :
    1. In the CheckReference sub procedure, change the Debug.Print statement as follows. This removes any missing reference to your project :
      Code:
      vbProj.References.Remove chkRef
    2. Run the CheckReference procedure.
    3. Verify that the reference was removed in the References dialog box (Tools menu, click References).

Similar Threads

  1. Replies: 1
    Last Post: 04-02-2013, 01:12 PM
  2. Replies: 5
    Last Post: 27-06-2012, 05:29 PM
  3. In Visual Basic How to check whether an Object exists??
    By Samarth in forum Software Development
    Replies: 4
    Last Post: 02-01-2010, 10:13 PM
  4. Visual Basic 2005 or Visual Basic 6
    By Aasha in forum Software Development
    Replies: 5
    Last Post: 15-01-2009, 06:56 PM
  5. Incorrect progressline - MS Project
    By Sjoerty in forum Windows Software
    Replies: 6
    Last Post: 11-11-2008, 05:48 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,508,497.23488 seconds with 16 queries