![]() |
|
![]() |
|
Thread Tools | Display Modes |
|
#1
|
||||
|
||||
![]()
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 |
![]() |
Tags |
runtime error 5941 |
|
![]() |
||||
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 |
![]() |
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 |