A Microsoft Excel forum. ExcelBanter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » ExcelBanter forum » Excel Newsgroups » Excel Programming
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

3d range names/references



 
 
Thread Tools Display Modes
  #1  
Old January 15th 07, 10:14 PM posted to microsoft.public.excel.programming
Bob Phillips
external usenet poster
 
Posts: 1,726
Default 3d range names/references

Where is the error?

What does vWorkbookPath hold?

What does sWorkheet hold?

--
---
HTH

Bob

(change the xxxx to gmail if mailing direct)


"alfaista" > wrote in message
...
>i hope this is the correct place to ask this question.
>
> i am accessing an Excel workbook from Access. i need to be able to get
> the
> value of a cell that has a 3d type of name/reference, i.e.
> Sheet1:Sheet2!$E$2
> = MyName.
> i need it named like this because i will need the value off one of those
> two
> worksheets, based on which one the user needs.
>
> here is some of my code...
> Dim xlApplication As Excel.Application
> Dim xlWorkbook As Excel.Workbook
> Dim xlWorksheet As Excel.Worksheet
>
> Set xlApplication = CreateObject("Excel.Application")
> Set xlWorkbook = GetObject(vWorkbookPath)
>
> xlWorkbook.Worksheets(sWorkSheet).Activate
>
> vAns = xlWorkbook.ActiveSheet.Range(sName)
>
> well, it doesn't work. says Application defined or Object defined error.
> is it possible to do what i am trying to do?
> if not, does anyone have any other ideas? i would prefer to not have
> MyName1, MyName2, etc....for all these identical cells on different
> worksheets.
>
> thanks in advance for any help!



Ads
  #2  
Old January 15th 07, 11:27 PM posted to microsoft.public.excel.programming
Bob Phillips
external usenet poster
 
Posts: 1,726
Default 3d range names/references

I wouldn't think you can get an object in a newly created instance of Excel,
there will be none.

You should open it, so instead of

Set xlWorkbook = GetObject(vWorkbookPath)

use

Set xlWorkbook = xlApplication.Workbooks.Open(vWorkbookPath)


--
---
HTH

Bob

(change the xxxx to gmail if mailing direct)


"alfaista" > wrote in message
...
> the error happens at this line:
> vAns = xlWorkbook.ActiveSheet.Range(sName)
>
> vWorkbookPath holds the entire location string of the file i need opened:
> "C:\Documents and Settings\Heidi Rose\My Documents\ExcelFile.xls"
>
> sWorksheet holds the string for the worksheet name chosen by the user:
> "Sheet1"
>
> thanks!
>
>
>
> "Bob Phillips" wrote:
>
>> Where is the error?
>>
>> What does vWorkbookPath hold?
>>
>> What does sWorkheet hold?
>>
>> --
>> ---
>> HTH
>>
>> Bob
>>
>> (change the xxxx to gmail if mailing direct)
>>
>>
>> "alfaista" > wrote in message
>> ...
>> >i hope this is the correct place to ask this question.
>> >
>> > i am accessing an Excel workbook from Access. i need to be able to get
>> > the
>> > value of a cell that has a 3d type of name/reference, i.e.
>> > Sheet1:Sheet2!$E$2
>> > = MyName.
>> > i need it named like this because i will need the value off one of
>> > those
>> > two
>> > worksheets, based on which one the user needs.
>> >
>> > here is some of my code...
>> > Dim xlApplication As Excel.Application
>> > Dim xlWorkbook As Excel.Workbook
>> > Dim xlWorksheet As Excel.Worksheet
>> >
>> > Set xlApplication = CreateObject("Excel.Application")
>> > Set xlWorkbook = GetObject(vWorkbookPath)
>> >
>> > xlWorkbook.Worksheets(sWorkSheet).Activate
>> >
>> > vAns = xlWorkbook.ActiveSheet.Range(sName)
>> >
>> > well, it doesn't work. says Application defined or Object defined
>> > error.
>> > is it possible to do what i am trying to do?
>> > if not, does anyone have any other ideas? i would prefer to not have
>> > MyName1, MyName2, etc....for all these identical cells on different
>> > worksheets.
>> >
>> > thanks in advance for any help!

>>
>>
>>



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to convert range names (about 100) to cell references? Kunjumol Excel Discussion (Misc queries) 1 March 27th 09 03:31 AM
range names to cell references Chris Excel Worksheet Functions 3 October 23rd 07 06:56 PM
Range Names convert to Cell References AlanC Excel Discussion (Misc queries) 10 September 21st 07 12:24 AM
How to rename references from range names to cell references Abbas Excel Discussion (Misc queries) 1 May 24th 06 06:18 PM
Replace range names with cell references? KH Excel Worksheet Functions 2 August 2nd 05 01:09 AM


All times are GMT +1. The time now is 08:07 AM.


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