How to link an object to a specific Excel sheet

Posted on 2008-01-29
Medium Priority
Last Modified: 2008-01-29
Hi expersts,

I use the following code from the help file:

    OLE1.Class = "Excel.Sheet"
    OLE1.OLETypeAllowed = acOLELinked
    OLE1.SourceDoc = "C:\Excel\Oletext.xls"
    OLE1.SourceItem = "R1C1:R5C5"
    OLE1.Action = acOLECreateLink

This works just fine except that it I can't figure out how to specify a different sheet as SourceItem
I tried several variations on OLE1.SourceItem = "'Sheet 2'!R1C1:R5C5", but nothing seems to work.

Any suggestions?

Question by:altiplano
  • 2
LVL 14

Expert Comment

ID: 20768542
Why not use a hyperlink?
LVL 44

Expert Comment

ID: 20768602
Did you try:  OLE1.SourceItem = "Sheet 2!R1C1:R5C5"

ie.  Remove the single quotes.
LVL 44

Accepted Solution

GRayL earned 600 total points
ID: 20768617
Sorry and remove the space:

OLE1.SourceItem = "Sheet2!R1C1:R5C5"


Author Comment

ID: 20771623
As so often there was a double problem. The quotes were indeed wrong (but the spaces are OK). The other problem however, was the length of the total string. Apparently there is some maximum length of about 50 (?) characters.

So this did not work:
    l_Sheet = "Some rather long sheet name with spaces"
    OLE1.SourceItem = l_Sheet & "!R1C1:R5C5"

but this did:
    l_Sheet = "Short name"
    OLE1.SourceItem = l_Sheet & "!R1C1:R5C5"

Featured Post

Easily Design & Build Your Next Website

Squarespace’s all-in-one platform gives you everything you need to express yourself creatively online, whether it is with a domain, website, or online store. Get started with your free trial today, and when ready, take 10% off your first purchase with offer code 'EXPERTS'.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

If you’re using QODBC to update QuickBooks data from Microsoft® Access but Access is not showing the updated data, you could have set up QODBC incorrectly.
A quick solution showing how to control and open a POS Cash Register Drawer using VBA with MS Access.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Enter Foreign and Special Characters Enter characters you can't find on a keyboard using its ASCII code ... and learn how to make a handy reference for yourself using Excel ~ Use these codes in any Windows application! ... whether it is a Micr…

619 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question