Error 1004: The specified dimension not valid for current chart type

dirtyamaha

New Member
Joined
Aug 14, 2014
Messages
2
I am relatively new to vba programming. I've figured out a number of things but this has me stumped.

This is what I am trying to do from a workbook where I have the vba code:

1) open a second workbook located elsewhere
2) save into another location
3) run some code on this second workbook

When I run the saveas, I get the 1004 error about the chart dimensions. At this point in the code, I haven't changed anything in the second workbook. This workbook does have a number of charts but if I save this manually, it does not have a problem.

I'm on excel 2010. I'm not sure what this is created on but the second workbook that is opened has no code in it. It was saved as a .xlsm by the guy who made it because he used an old workbook as a starting point.

Here is the snippet of code that opens and saves the workbook. I can post more if it would be helpful.
Code:
'open template    Application.Calculation = xlManual
    Workbooks.Open (TempPath & "\Template " & Cells(i, 2).Text & ".xlsm")
    
    'add a chart to set default charttype
    Set WS = Sheets.Add
    Set chtTemp = Charts.Add
    With chtTemp
        .ChartType = xlLine
        .SetSourceData source:=WS.Range("A1:B10")
    'Set chtTemp = WS.Shapes.AddChart(xlColumnClustered, 1, 1, 100, 100).Chart
    
    End With
    
    ActiveWorkbook.Saved = True
    ActiveWorkbook.SaveAs Filename:=SavePath & CltName & "\Performance\" & FirstName & " " & AcctType & _
        " " & TemplateType & ".xlsm", FileFormat:=52

The lines for adding a chart were part of my attempt to create a new chart to establish a default chart type.

Please help if you can. I don't know where to go from here.
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
I thought I'd post an update in case someone else is researching this error. I figured out my problem. My error had nothing to do with charts or dimensions. In my save path, I created a client name that is in the format of

lastname, firstname

The problem was, I didn't realize the folders were using a period instead of a comma:

lastname. firstname

I fixed this and saves are working fine.
 
Upvote 0

Forum statistics

Threads
1,215,260
Messages
6,123,926
Members
449,135
Latest member
NickWBA

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top