Results 1 to 4 of 4
  1. #1
    TrulyVisceral is offline Total N00B
    Windows 8 Access 2010 64bit
    Join Date
    Mar 2018
    Location
    Deimos
    Posts
    102

    Lightbulb Exporting graphs from a form.

    Ok so, a little bit of investigation I found this:



    Code:
    Private Sub Export_Click()
    
    Dim graphExport As Object
    
    Set graphExport = Me.Ctl3PPContractChart.Object
    graphExport.Export "C:\3PP Exported Charts\" & vendor & ".jpg", "JPEG"
    Set graphExport = Nothing
    Me.Ctl3PPContractChart.Action = acOLEClose
    
    End Sub
    BUT, I don't fully get it. The small thread I found this in doesn't really explain it. Nor does it have much context.

    1)I'm assuming that "Ctl3PPContractChart" is the name of the graph itself. But what's "graphExport" for? Is it a function or another variable? The person who made the code said their graphs are in a subform, is that it?

    2)I'm given an error saying that "vendor" is an undefined variable, would that be part of the query the chart is being taken from? Changing it into a variable of my chart (provider) doesn't fix it.

    3)As for acOLEClose, I'm not quite sure, I tried searching what an OLE object is, but it seems that part is necessary.

    Sorry, not quite got the hang of VB. However, they say this was made with
    Microsoft Graphs 2000, I made mine within Access. And they also explain their graphs are in a subform, mine aren't, that would probably change a lot.

    EDIT: As I'm writing this, my supervisor said he doesn't care about mass exporting all the graphs, so long as the raw data can be (and I have a button for that). He only needs a handful of the graphs for the PowerPoint presentation, so he can copy paste a few select ones no prob. So this is, as he puts it, "makeup".

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    what about:

    vFile = "c:\folder" & vRpt & ".pdf"
    docmd.OutputTo acOutputForm ,"frmGraph",acFormatPDF,vFile

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,825
    graphExport is an object variable. This object variable has properties and methods the actual graph on the form does not have.

    vendor was probably a field in the form's RecordSource for the original code.

    The following works for me, no subform involved:

    Code:
    Private Sub ExpGrph_Click()
    Dim graphExp As Object
    Set graphExp = Me.Graph11
    graphExp.Export "C:\images\Graph11.jpg", "jpeg"
    End Sub
    If you want the filename to be dynamically constructed based on some value in a field, then use the concatenation syntax. Must reference field of the form's RecordSource or name of textbox.

    graphExp.Export "C:\yourfolderpath\" & Me.provider & ".jpg", "jpeg"

    But this doesn't help your boss place the jpg images on PowerPoint slide. Copy/paste just might be easiest approach.

    I tried to find a way to link PowerPoint graphs to Access data but apparently they must be based on Excel.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  4. #4
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,954
    You might be interested in this post which shows a very simple method of populating PowerPoint slides from Access.
    https://www.access-programmers.co.uk...03&postcount=9
    The code isn't mine - it's by an AWF member called JHB.
    Ignore any clunkiness in the end result.
    That's due to the OP's code which JHB based his solution on
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

Please reply to this thread with any new information or opinions.

Similar Threads

  1. graphs
    By chr1stoper1 in forum Access
    Replies: 3
    Last Post: 08-08-2015, 11:11 AM
  2. Sorting Graphs?
    By McArthurGDM in forum Reports
    Replies: 2
    Last Post: 05-11-2015, 01:17 PM
  3. Replies: 0
    Last Post: 11-30-2011, 02:01 PM
  4. Graphs
    By thewabit in forum Forms
    Replies: 1
    Last Post: 01-17-2010, 10:52 PM
  5. Help with Graphs.
    By Rameez in forum Access
    Replies: 0
    Last Post: 06-29-2009, 01:41 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums