Results 1 to 5 of 5

Picture Export Not Functional from Button

Threaded View

  1. #1
    Forum Contributor
    Join Date
    12-02-2010
    Location
    Boise, Idaho
    MS-Off Ver
    Excel 2013, 2016
    Posts
    100

    Picture Export Not Functional from Button

    Hello All,

    The issue I am having is that my code works perfectly when I step through it in the VBA window but when I assign the same macro to a button and run it from the sheet it doesn't work properly.

    I am copying a group and pasting it as a chart object for exporting as an image, but when I am running it off a button the image is blank. When I run each step in the VBA window it exports with the image in it properly.

    My code is as follows:
    Sub export_linear()
    Dim myFileName As String
    Dim fullpathandfilename As String
    Dim mypath As String
    Dim mygroup As Object
    Dim chtObj As Object
    
    Application.ScreenUpdating = False
    mypath = ActiveWorkbook.path
    
    Set mygroup = Worksheets("Linear_Gauge").Shapes("Group 17")
    mygroup.CopyPicture
    
    Set chtObj = ActiveSheet.ChartObjects.Add(mygroup.Left, mygroup.Top, mygroup.Width, mygroup.Height)
    
    chtObj.Name = "Grouped 2"
    chtObj.Chart.Paste
    
    ActiveSheet.Shapes("Grouped 2").ScaleWidth 1.75, msoFalse, msoScaleFromTopLeft
    ActiveSheet.Shapes("Grouped 2").ScaleHeight 1.75, msoFalse, msoScaleFromTopLeft
    
    myTime = Format(TimeValue(Now), "hh.mm.ss am/pm")
    myFileName = Range("O2").Value & " (" & myTime & ").png"
    fullpathandfilename = ThisWorkbook.path & "\" & myFileName
    
    On Error Resume Next
    Kill (path)
    chtObj.Chart.export Filename:=fullpathandfilename, Filtername:="PNG"
    
    chtObj.Delete
    Set chtObj = Nothing
    
    Application.ScreenUpdating = True
    
    End Sub
    It seems to not be recognizing/performing the "chtObj.Chart.Paste" operation. I have attempted to add some wait operations in there in case it was running through lines faster than my computer could keep up, that's also why I have screenupdating = False.

    Any help on how to resolve this issue would be greatly appreciated.

    Thank you.
    Last edited by DarkF1ame; 06-22-2017 at 07:54 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Export picture from sheet
    By Temporary-Failure in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-20-2016, 12:17 PM
  2. [SOLVED] Insert Picture in cell, click commanbutton to rename picture, lock cell and remove button
    By thecdnmole in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-28-2014, 10:05 PM
  3. Hide a picture button placed in all sheets using a option button (form control)
    By lagaranch in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-26-2012, 10:33 AM
  4. Export picture containing both chart and range...
    By asgersax in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-22-2012, 04:56 AM
  5. export and save worksheet as a picture.
    By Diesel13 in forum Excel General
    Replies: 18
    Last Post: 10-22-2010, 05:04 PM
  6. Export as picture
    By tommy_gtr in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 11-02-2005, 06:20 PM
  7. export range as picture
    By manolo in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-13-2005, 06:05 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1