Solved

Reference Excel Chart in Access Unbound Object Frame using Sourceitem property

Posted on 2010-08-12
18
2,647 Views
Last Modified: 2013-11-27
I can't for the life of me figure out to reference an Excel chart in my Access form Unbound Object Frame using the "Sourceitem" property. I need to embed multiple charts (not just pictures of the chart)into my Access form using the OLE Unbound Object Frame. I have the "SourceDoc" property correct as this is just the filepath to my Excel file. However I can't seem to reference the specific charts on the worksheets (Which are seperate chart sheets from the actual data). Attached is an example of the non-workng code. It currently returns only the active cells in the worksheet. I've been struggling with this for days !!! Thanks.

*The Excel File Name = Spend Management 7-19-2010.xlsx
*The Worksheet(Chart Sheet) Name = Direct-Charts
*Chart Name = Chart 35
With dtb

'.Visible = True
     ' Enable control.
     '.Enabled = True
     ' Set Locked property to False.
     '.Locked = False
     ' Allow embedded objects only.
     '.OLETypeAllowed = acOLEEmbedded
     ' Specify the OLE server and the type of object.
     '.Class = "Excel.Chart.8"
     ' Specify the file to be embedded.
     '.SourceDoc = "G:\000_Supply Chain\Procurement-Corporate\Spend Management\Spend Management 7-19-2010.xlsx"
     ' Specify the Worksheet Item
     '.SourceItem = "Direct - Charts![Spend Management 7-19-2010.xlsx].Chart 35"
     ' Create the embedded object.
     '.Action = acOLECreateEmbed
 ' End With

Open in new window

0
Comment
Question by:RichBLACKIII
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 3
  • 3
  • +2
18 Comments
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 33426178
Have you tried simply copying the Excel chart, then on the Access form, Select:
Paste Special-->Microsoft Office Excel Chart?

This works fine for me...

;-)

JeffCoachman
0
 

Author Comment

by:RichBLACKIII
ID: 33426617
No, that's not going to work. I have multiple charts that need to be loaded into the same unbound object frame at different times when I run a different macro through command buttons on my form.

Gosh, I didn't think this question would be this hard ???...I guess it must be if google couldn't provide an answer :\

 
0
 
LVL 44

Expert Comment

by:GRayL
ID: 33442720
Although it says worksheet, it is actually a workbook.  You have to start from there.  What is the workbook(sheet) name?
0
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

 

Author Comment

by:RichBLACKIII
ID: 33442755
*The Excel File Name = Spend Management 7-19-2010.xlsx
*The Worksheet(Chart Sheet) Name = Direct-Charts
*Chart Name = Chart 35

I have this in the question already.
0
 
LVL 60

Expert Comment

by:Kevin Cross
ID: 33498411
I believe your issue to be here:

.SourceItem = "Direct - Charts![Spend Management 7-19-2010.xlsx].Chart 35"

Since the names have spaces in them, I believe you will want to surround them with []. But as I believe was GrayL's point here - http:#a33442720 - you will want to start with the Excel sheet name.

.SourceItem = "[Direct - Charts]![Chart 35]"
or
.SourceItem = "[Direct - Charts].[Chart 35]"

You are already opening the Excel workbook as the source document.
0
 

Author Comment

by:RichBLACKIII
ID: 33504675
SourceItem = "[Direct - Charts]![Chart 35]"
or
.SourceItem = "[Direct - Charts].[Chart 35]"

The syntax you gave is still incorrect. The Excel file opens but just embeds the active workbook cells.
0
 
LVL 44

Expert Comment

by:GRayL
ID: 33504842
Open the form in design view, display Properties, click Data tab, click SourceItem, press F1 and you get a detailed explanation of how to reference the elements in Excel.
0
 

Author Comment

by:RichBLACKIII
ID: 33505376
Yes, GRayL I know how to use the Sourceitem property. The exact problem I am having is how to reference an Excel Chart on a Excel Chart Sheet. The help menu does not give the syntax for that situation.
0
 
LVL 60

Expert Comment

by:Kevin Cross
ID: 33505512
VBA > Worksheets("{sheetname}").ChartObjects(n).Chart
http://msdn.microsoft.com/en-us/library/aa213725(office.11).aspx
0
 

Author Comment

by:RichBLACKIII
ID: 33515482
VBA > Worksheets("{sheetname}").ChartObjects(n).Chart
http://msdn.microsoft.com/en-us/library/aa213725(office.11).aspx

This does not work with the sourceitem property.
0
 
LVL 44

Expert Comment

by:GRayL
ID: 33524927
I got from the Help extract that the SourceItem had to be a cell or cell range.  ie.  It could not be a chart.
0
 
LVL 17

Accepted Solution

by:
calacuccia earned 500 total points
ID: 33537682
In this thread, the syntax is slightly differenet http://www.pcreview.co.uk/forums/thread-1154811.php
Of course, there it's referring to a sheet embedded chart, maybe wort a try to place the Chart in a worksheet and do it this way?

Also here, it is mentioned to be working I believe http://forums.techguy.org/business-applications/568565-open-excel-chart-access-2003-a.html

Have you tried much shorter statements?

'.SourceItem = "Direct - Charts"
(eventually wit [] or '   ' around them?
0
 
LVL 60

Expert Comment

by:Kevin Cross
ID: 33703772
Think GrayL is right here: http:#a33524927
0
 

Author Closing Comment

by:RichBLACKIII
ID: 33727532
It's close enough
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

734 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