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! |
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! |
All times are GMT +1. The time now is 11:44 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com