LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
bz bz is offline
external usenet poster
 
Posts: 16
Default variant/error Error 2023

I am using the following code

' Create the argument
arg = "'" & path & "[" & file & "]" & sheet & "'!" & _
Range(ref).Range("A1").Address(, , xlR1C1)
' Execute an XLM macro
GetValue = ExecuteExcel4Macro(arg)

to fetch values from cells in a closed excel workbook.

IF I attempt to fetch the value from an _empty cell_, ExecuteExcel4Macro
returns a variant/error object containing
Error 2023

How can I test the returned object, which should NORMALLY be a string, so
that I can ignore the error?

I want to do something like this:
if GetValue is typoe variant/error then
GetValue = ""
end if

but I can't figure out the correct syntax to do this.
When I try to do something like
On Error goto badvalue
goto good value
badvalue: on error resume next
GetValue = ""
Goodvalue: end subroutine

It either goes into an endless loop or the user sees an error message that
means nothing to them, "type mismatch"

How can I test the Type of GetValue and act upon it?

--
bz

please pardon my infinite ignorance, the set-of-things-I-do-not-know is an
infinite set.

remove ch100-5 to avoid spam trap
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to solve Error 2023 for Excel? Eric Excel Worksheet Functions 0 July 1st 07 02:24 PM
Runtime error 13-- Setting a variant Range?! [email protected] Excel Programming 3 September 11th 06 07:03 PM
Error Handling - On Error GoTo doesn't trap error successfully David Excel Programming 9 February 16th 06 05:59 PM
Array problem: Key words-Variant Array, single-element, type mismatch error davidm Excel Programming 6 November 9th 05 05:54 AM
Array problem: Key words-Variant Array, single-element, type mismatch error davidm Excel Programming 1 November 8th 05 04:21 AM


All times are GMT +1. The time now is 09:00 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"