Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #3  
Old 12-12-2014, 07:07 PM
macropod's Avatar
macropod macropod is offline Searching Arrays without Loops? Windows 7 64bit Searching Arrays without Loops? Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Perhaps:
Code:
Sub Test()
    Dim f, xlWorkBook, NmdValue As Object
    Dim Bm, Nm As Variant
    Dim Bmk, NmdRng As String
    'Choose the Excel File
    Set f = Application.FileDialog(msoFileDialogFilePicker)
    f.Title = "Please Select A New File"
    f.AllowMultiSelect = False
    f.Filters.Clear
    f.Filters.Add "Microsoft Excel Files", "*.xls, *.xlsb, *.xlsm, *.xlsx" 'Limit to Excel Files Only
    If f.Show = -1 Then
        Set xlWorkBook = GetObject(f.SelectedItems(1))
    Else 'user clicked cancel
        Exit Sub
    End If
             
    ' Check Each NamedRanged in the Excel File for a Matching BookMark
    For Each Nm In xlWorkBook.Names
      NmdRng = Nm.Name
      If ActiveDocument.Bookmarks.Exists(NmdRng) = True Then
        Set NmdValue = xlWorkBook.Names(NmdRng).RefersToRange
        'Update the found bookmark
        ActiveDocument.Bookmarks(Bmk).Range.InsertAfter NmdValue
      End If
    Next
    ActiveDocument.Bookmarks.ShowHidden = True
    ActiveWindow.View.ShowBookmarks = False
End Sub
Sub UpdateBM(BookmarkToUpdate As String, TextToUse As String)
    Dim BMRange As Range
    Set BMRange = ActiveDocument.Bookmarks(BookmarkToUpdate).Range
    BMRange.Text = TextToUse
    ActiveDocument.Bookmarks.Add BookmarkToUpdate, BMRange
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
 

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Filling cells with random numbers using loops? (VBA) Sajj Excel Programming 4 04-10-2013 02:29 PM
Searching Arrays without Loops? re-naming arrays in VBA? JDevsFan Excel Programming 4 03-15-2012 08:44 AM
HTML in email loops endlessly rbtroj Outlook 0 05-19-2011 12:29 PM
Searching Arrays without Loops? Powerpoint loops, but not to beginning imeister PowerPoint 1 02-02-2011 02:05 PM
loops within presentations supateach PowerPoint 1 11-23-2010 04:42 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 08:31 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft