+ Reply to Thread
Results 1 to 2 of 2

Chart and/or SaveAs issue

Hybrid View

  1. #1
    Registered User
    Join Date
    04-11-2012
    Location
    Auburn, AL
    MS-Off Ver
    Excel 2007
    Posts
    2

    Chart and/or SaveAs issue

    Hello all,
    I'm having an issue with a bit of code on a workbook_open() event. The small bit of code refreshes external data links, then loops through each chart and saves them out to a network drive, then saves the workbook as a different name. This is to provide a production copy that updates automatically and a "read-only" copy for people who want to simply view the updated copy. The problem is that the code hangs on the SaveAs line (see below), but the error gives reference to 'chart dimensions'. The network path is good, available, and the user has right to save there. After the debug, I can manually save it, just not sure why it hangs there as I use this line in several other workbooks.

    Here's the code.
    Private Sub Workbook_Open()
    
    Dim cht As ChartObject
    
    If ThisWorkbook.Name = ("DigitalSignage.xls") Then
    
    Application.DisplayAlerts = False
    'ThisWorkbook.RefreshAll
    
    ActiveWorkbook.RefreshAll
    
    ActiveWorkbook.Worksheets("GRAPHS").Activate
    
    For Each cht In ActiveSheet.ChartObjects
    
    cht.Activate
    ActiveChart.Export "\\pltaub2\prod$\Aub\Auto_Reports\DigitalSignage\Display\Charts\" & cht.Name & ".png"
    
    Debug.Print cht.Name
    
    
    Next cht
    
    ActiveWorkbook.SaveAs "\\pltaub2\prod$\Aub\Auto_Reports\DigSign.xlsm", FileFormat:=52
    Application.Quit
    
    Else
    ''
    
    End If
    
    End Sub
    The error is below.
    Run-time error '1004':
    The specified dimension is not valid for the current chart type.
    http://i.imgur.com/hBUrI.png

    The funny thing is that I'm not specifying any dimensions for any chart. Also, the Debug.Print lists all of my charts, so it seems to be completing the For Next Loop.
    Any help or insight appreciated.

    Thanks in advance,
    sirluke34

  2. #2
    Registered User
    Join Date
    04-11-2012
    Location
    Auburn, AL
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: Chart and/or SaveAs issue

    Update:

    The only way I could get this to function properly was to have the destination file save in the same directory as the source file. It's odd because it has been working the old way for about 2 months. This Sunday, the file started to not work properly with that code.

    Regardless, here is the code I used to fix it.

    Dim cht As ChartObject
    Dim strPath As String
    Dim strFile As String
    
    
    If ThisWorkbook.Name = ("DigitalSignage.xlsm") Then
    
    Application.DisplayAlerts = False
    'ThisWorkbook.RefreshAll
    
    ActiveWorkbook.RefreshAll
    
    ActiveWorkbook.Worksheets("GRAPHS").Activate
    
    strPath = ActiveWorkbook.path
    strFile = "DigSign.xlsx"
    
    For Each cht In ActiveSheet.ChartObjects
    
    cht.Activate
    ActiveChart.Export "\\pltaub2\prod$\Aub\Auto_Reports\DigitalSignage\Display\Charts\" & cht.Name & ".png"
    
    Debug.Print cht.Name
    
    
    Next cht
    
    
    'ActiveWorkbook.SaveAs "\\pltaub2\prod$\Aub\Auto_Reports\DigSign.xlsx", FileFormat:=51
    ActiveWorkbook.SaveAs strPath & strFile, FileFormat:=51
    Application.Quit
    
    Else
    ''
    
    End If

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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