[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.6

Using selected items in listbox within another procedure - VBA

Asked by wobbled in Microsoft Word

Tags: vba, listbox, items

I have a form frmReplaceLinks that has a listbox on it lstFileLinkPaths set to mulitselectoption.  

Currently the code below loops through the active document and changes all the OLE paths to that set in the variable strNewPath.  This works fine, but I need to alter it so that it ONLY changes the OLE paths of those items selected in the listbox. I have had a few attempts in changing the code to do this but upto now no success.  Any ideas?

Thanks


Sub SelectedChangeLinks()

    Dim ilsh As InlineShape
    Dim strFileName As String
    Dim vParts As Variant
    Dim vFileName As Variant
    Dim lgCountOLE As Long
    Dim lgStopCount As Long
    Dim strNewPath As String
    Dim i As Long
    Dim errNum As Long
    Dim fso As New Scripting.FileSystemObject 'ref to the Microsoft Scripting Runtime
    Dim appBgdExcel As Object
    Dim lgI As Long

    Set appBgdExcel = New clsExcel  'speeds up the process by opening excel in the background
   
    strNewPath = frmReplaceLinks.txtFindNewLinkLocation.Value
       
    lgCountOLE = 0
    lgStopCount = 0
    errNum = 0
         
    'Counts the links
    For Each ilsh In ActiveDocument.InlineShapes
        lgCountOLE = lgCountOLE + 1
    Next ilsh
   
    'Have to run from the bottom up otherwise creates a continous loop
   For i = ActiveDocument.InlineShapes.Count To 1 Step -1
        Set ilsh = ActiveDocument.InlineShapes(i)
       
            StatusBar = "Updating " & i & " of " & lgCountOLE & " linked objects in this document..."
           
            If ilsh.Type = wdInlineShapeLinkedOLEObject Then
                vParts = fso.GetParentFolderName(strNewPath)
                vFileName = fso.GetFileName(strNewPath)
                             
               On Error GoTo Err_ChangeLinks
                'Error 6083 appears each time the following line is run, by
                'repeating the line of code it then works???
               ilsh.LinkFormat.SourceFullName = vParts & "\" & vFileName
               errNum = 0
               On Error GoTo 0
               
               DoEvents
                               
            End If
       
    Next i
   

    StatusBar = "Links Updated...."
   
    Call SetLinksManual
   
    MsgBox "Update of links completed successfully" & vbLf & vbLf & _
    lgCountOLE & " links were updated to the the file:" & vbLf & _
    strNewPath & vbLf, vbInformation, "Updated Successfull"
     
   
Unload frmReplaceLinks

Exit Sub

Err_ChangeLinks:
   
    If Err.Number = 6083 And errNum < 2 Then
        errNum = errNum + 1
        Resume
    Else
        Debug.Print Err.Number & " " & Err.Description
    End If

   
End Sub
[+][-]11/09/05 04:49 AM, ID: 15255537Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zone: Microsoft Word
Tags: vba, listbox, items
Sign Up Now!
Solution Provided By: GrahamSkan
Participating Experts: 1
Solution Grade: A
 
[+][-]11/09/05 02:55 AM, ID: 15255083Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/09/05 06:41 AM, ID: 15256354Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-92