Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 06-03-2021, 05:11 PM
Guessed's Avatar
Guessed Guessed is offline PLEASE HELP: Run-time error '5941', The requested member of the collection does not exist Windows 10 PLEASE HELP: Run-time error '5941', The requested member of the collection does not exist Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,176
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

For the Range Value you would get the same number format as Excel simply by using
.Sheets(i).Range(RangeName).Text
instead of
.Sheets(i).Range(RangeName).Value
You could then do away with a bunch of the fiddly code trying to replicate that.

Your code to return the RangeValue has an error handler but it makes a fatal assumption that the named range is a single cell. So not only does the bookmark name in Word need to exist in the Excel workbook (that the user selected), but the capitalisation of the bookmark/name must match and it must be only a single cell. A clean way to deal with the capitalisation issue is shown here Excel Named Ranges - Does a Named Range Exist



To also handle the possibility of the Excel named range existing but being more than one cell, lets assume that you want the value in the first cell
.Sheets(i).Range(RangeName).Cells(1).Text

Post a sample document and workbook pair if you want the code fixed so that it works with your sample. It is much easier for us to work out the code flaws when we see what your ACTUAL input is.
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
Reply

Tags
runtime error 5941



Similar Threads
Thread Thread Starter Forum Replies Last Post
Word template with Macro keeps getting an error ''Run-time error 5941'' Marcel Word VBA 3 12-17-2019 04:55 PM
PLEASE HELP: Run-time error '5941', The requested member of the collection does not exist Word 2010 the requested member of the collection does not exist flyboy3300 Word VBA 15 08-02-2016 01:40 AM
Presentation (unknown member) : Object does not exist. Benazeer PowerPoint 0 03-08-2016 06:28 AM
Run-time error 5941 when deleting a row from a table jpb103 Word VBA 1 05-26-2014 07:08 AM
5941 requested member of collection does not exist Prevents Userform from Showing marksm33 Word VBA 1 02-22-2014 08:56 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 08:24 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