![]() |
Compile Error in Code
In the following code, I receive a compile error: Sub or
Function not defined. In the fifth line, "ChartObjects" is highlighted. Can someone help me clear this problem? Sub GoToMetricsA1() ' GoToMetricsA1 Macro Sheets("Metrics").Select Range("A1").Select ChartObjects("Chart13").activate With ActiveChart.Parent .Height = 250 ' use desired height in points .Width = 350 ' use desired width in points .Left = (Windows(ActiveWorkbook.Name).Width - _ .Width)/2 .Top = (Windows(ActiveWorkbook.Name).Height - _ .Height)/2 End With End Sub |
Compile Error in Code
Phil,
Use ActiveSheet.ChartObjects("Chart13").Activate -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "Phil Hageman" wrote in message ... In the following code, I receive a compile error: Sub or Function not defined. In the fifth line, "ChartObjects" is highlighted. Can someone help me clear this problem? Sub GoToMetricsA1() ' GoToMetricsA1 Macro Sheets("Metrics").Select Range("A1").Select ChartObjects("Chart13").activate With ActiveChart.Parent .Height = 250 ' use desired height in points .Width = 350 ' use desired width in points .Left = (Windows(ActiveWorkbook.Name).Width - _ .Width)/2 .Top = (Windows(ActiveWorkbook.Name).Height - _ .Height)/2 End With End Sub |
Run-time Error '1004'
Thanks for your help Chip - appreciate your time.
I entered the change, per the following, and received Run- time error '1004': "Unable to get the ChartObjects property of the Worksheet class." The ActiveSheet... line is highlighted yellow. Did I put this in wrong? Thanks, Phil Sub GoToMetricsA1() ' GoToMetricsA1 Macro Sheets("Metrics").Select Range("A1").Select ActiveSheet.ChartObjects("Chart13").Active With ActiveChart.Parent .Height = 250 'use desired height in points .Width = 350 'use desired width in poits .Left = (Windows(ActiveWorkbook.Name).Width - .Width) / 2 .Top = (Windows(ActiveWorkbook.Name).Height - .Height) / 2 End With End Sub -----Original Message----- Phil, Use ActiveSheet.ChartObjects("Chart13").Activate -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "Phil Hageman" wrote in message ... In the following code, I receive a compile error: Sub or Function not defined. In the fifth line, "ChartObjects" is highlighted. Can someone help me clear this problem? Sub GoToMetricsA1() ' GoToMetricsA1 Macro Sheets("Metrics").Select Range("A1").Select ChartObjects("Chart13").activate With ActiveChart.Parent .Height = 250 ' use desired height in points .Width = 350 ' use desired width in points .Left = (Windows(ActiveWorkbook.Name).Width - _ .Width)/2 .Top = (Windows(ActiveWorkbook.Name).Height - _ .Height)/2 End With End Sub .. |
Run-time Error '1004'
ActiveSheet.ChartObjects("Chart13").Active
should be ActiveSheet.ChartObjects("Chart13").Activate or ActiveSheet.ChartObjects("Chart13").Select -- Regards, Tom Ogilvy "Phil Hageman" wrote in message ... Thanks for your help Chip - appreciate your time. I entered the change, per the following, and received Run- time error '1004': "Unable to get the ChartObjects property of the Worksheet class." The ActiveSheet... line is highlighted yellow. Did I put this in wrong? Thanks, Phil Sub GoToMetricsA1() ' GoToMetricsA1 Macro Sheets("Metrics").Select Range("A1").Select ActiveSheet.ChartObjects("Chart13").Active With ActiveChart.Parent .Height = 250 'use desired height in points .Width = 350 'use desired width in poits .Left = (Windows(ActiveWorkbook.Name).Width - .Width) / 2 .Top = (Windows(ActiveWorkbook.Name).Height - .Height) / 2 End With End Sub -----Original Message----- Phil, Use ActiveSheet.ChartObjects("Chart13").Activate -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "Phil Hageman" wrote in message ... In the following code, I receive a compile error: Sub or Function not defined. In the fifth line, "ChartObjects" is highlighted. Can someone help me clear this problem? Sub GoToMetricsA1() ' GoToMetricsA1 Macro Sheets("Metrics").Select Range("A1").Select ChartObjects("Chart13").activate With ActiveChart.Parent .Height = 250 ' use desired height in points .Width = 350 ' use desired width in points .Left = (Windows(ActiveWorkbook.Name).Width - _ .Width)/2 .Top = (Windows(ActiveWorkbook.Name).Height - _ .Height)/2 End With End Sub . |
Run-time Error '1004'
Thanks, Chip - I misread the word, and indeed, there is a
space in the chart name. My mistakes. Thanks for helping. Phil -----Original Message----- Phil, First off, the line ActiveSheet.ChartObjects("Chart13").Active should be ActiveSheet.ChartObjects("Chart13").Activate Second, are you sure you have a chart object named Chart13. You'll get the error you got if no chart with that name exists. You might need a space between 'Chart' and '13'. -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "Phil Hageman" wrote in message ... Thanks for your help Chip - appreciate your time. I entered the change, per the following, and received Run- time error '1004': "Unable to get the ChartObjects property of the Worksheet class." The ActiveSheet... line is highlighted yellow. Did I put this in wrong? Thanks, Phil Sub GoToMetricsA1() ' GoToMetricsA1 Macro Sheets("Metrics").Select Range("A1").Select ActiveSheet.ChartObjects("Chart13").Active With ActiveChart.Parent .Height = 250 'use desired height in points .Width = 350 'use desired width in poits .Left = (Windows(ActiveWorkbook.Name).Width - .Width) / 2 .Top = (Windows(ActiveWorkbook.Name).Height - .Height) / 2 End With End Sub -----Original Message----- Phil, Use ActiveSheet.ChartObjects("Chart13").Activate -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "Phil Hageman" wrote in message ... In the following code, I receive a compile error: Sub or Function not defined. In the fifth line, "ChartObjects" is highlighted. Can someone help me clear this problem? Sub GoToMetricsA1() ' GoToMetricsA1 Macro Sheets("Metrics").Select Range("A1").Select ChartObjects("Chart13").activate With ActiveChart.Parent .Height = 250 ' use desired height in points .Width = 350 ' use desired width in points .Left = (Windows (ActiveWorkbook.Name).Width - _ .Width)/2 .Top = (Windows (ActiveWorkbook.Name).Height - _ .Height)/2 End With End Sub . . |
Run-time Error '1004'
Thanks for the help, Tom. Chip pointed to two mistakes I
made - carelessness on my part. Could you answer a question: I need to manipulate the screen position of the chart. As this code works, the chart is positioning in the upper left corner. Thanks, Phil -----Original Message----- ActiveSheet.ChartObjects("Chart13").Active should be ActiveSheet.ChartObjects("Chart13").Activate or ActiveSheet.ChartObjects("Chart13").Select -- Regards, Tom Ogilvy "Phil Hageman" wrote in message ... Thanks for your help Chip - appreciate your time. I entered the change, per the following, and received Run- time error '1004': "Unable to get the ChartObjects property of the Worksheet class." The ActiveSheet... line is highlighted yellow. Did I put this in wrong? Thanks, Phil Sub GoToMetricsA1() ' GoToMetricsA1 Macro Sheets("Metrics").Select Range("A1").Select ActiveSheet.ChartObjects("Chart13").Active With ActiveChart.Parent .Height = 250 'use desired height in points .Width = 350 'use desired width in poits .Left = (Windows(ActiveWorkbook.Name).Width - .Width) / 2 .Top = (Windows(ActiveWorkbook.Name).Height - .Height) / 2 End With End Sub -----Original Message----- Phil, Use ActiveSheet.ChartObjects("Chart13").Activate -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "Phil Hageman" wrote in message ... In the following code, I receive a compile error: Sub or Function not defined. In the fifth line, "ChartObjects" is highlighted. Can someone help me clear this problem? Sub GoToMetricsA1() ' GoToMetricsA1 Macro Sheets("Metrics").Select Range("A1").Select ChartObjects("Chart13").activate With ActiveChart.Parent .Height = 250 ' use desired height in points .Width = 350 ' use desired width in points .Left = (Windows (ActiveWorkbook.Name).Width - _ .Width)/2 .Top = (Windows (ActiveWorkbook.Name).Height - _ .Height)/2 End With End Sub . . |
Run-time Error '1004'
For me it was centered on the screen.
Is the chart smaller than the visible window? Perhaps you need to check the values you are passing to top and left to see what is calculated. -- Regards, Tom Ogilvy "Phil Hageman" wrote in message ... Thanks for the help, Tom. Chip pointed to two mistakes I made - carelessness on my part. Could you answer a question: I need to manipulate the screen position of the chart. As this code works, the chart is positioning in the upper left corner. Thanks, Phil -----Original Message----- ActiveSheet.ChartObjects("Chart13").Active should be ActiveSheet.ChartObjects("Chart13").Activate or ActiveSheet.ChartObjects("Chart13").Select -- Regards, Tom Ogilvy "Phil Hageman" wrote in message ... Thanks for your help Chip - appreciate your time. I entered the change, per the following, and received Run- time error '1004': "Unable to get the ChartObjects property of the Worksheet class." The ActiveSheet... line is highlighted yellow. Did I put this in wrong? Thanks, Phil Sub GoToMetricsA1() ' GoToMetricsA1 Macro Sheets("Metrics").Select Range("A1").Select ActiveSheet.ChartObjects("Chart13").Active With ActiveChart.Parent .Height = 250 'use desired height in points .Width = 350 'use desired width in poits .Left = (Windows(ActiveWorkbook.Name).Width - .Width) / 2 .Top = (Windows(ActiveWorkbook.Name).Height - .Height) / 2 End With End Sub -----Original Message----- Phil, Use ActiveSheet.ChartObjects("Chart13").Activate -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "Phil Hageman" wrote in message ... In the following code, I receive a compile error: Sub or Function not defined. In the fifth line, "ChartObjects" is highlighted. Can someone help me clear this problem? Sub GoToMetricsA1() ' GoToMetricsA1 Macro Sheets("Metrics").Select Range("A1").Select ChartObjects("Chart13").activate With ActiveChart.Parent .Height = 250 ' use desired height in points .Width = 350 ' use desired width in points .Left = (Windows (ActiveWorkbook.Name).Width - _ .Width)/2 .Top = (Windows (ActiveWorkbook.Name).Height - _ .Height)/2 End With End Sub . . |
Positioning
Yes, the chart is smaller than the screen. I made the
height 550 and width 650, so I sized it smaller than the screen. The code has /2 at the end of the coding line. I've tried changing them, but the chart remains in the upper left corner. -----Original Message----- For me it was centered on the screen. Is the chart smaller than the visible window? Perhaps you need to check the values you are passing to top and left to see what is calculated. -- Regards, Tom Ogilvy "Phil Hageman" wrote in message ... Thanks for the help, Tom. Chip pointed to two mistakes I made - carelessness on my part. Could you answer a question: I need to manipulate the screen position of the chart. As this code works, the chart is positioning in the upper left corner. Thanks, Phil -----Original Message----- ActiveSheet.ChartObjects("Chart13").Active should be ActiveSheet.ChartObjects("Chart13").Activate or ActiveSheet.ChartObjects("Chart13").Select -- Regards, Tom Ogilvy "Phil Hageman" wrote in message ... Thanks for your help Chip - appreciate your time. I entered the change, per the following, and received Run- time error '1004': "Unable to get the ChartObjects property of the Worksheet class." The ActiveSheet... line is highlighted yellow. Did I put this in wrong? Thanks, Phil Sub GoToMetricsA1() ' GoToMetricsA1 Macro Sheets("Metrics").Select Range("A1").Select ActiveSheet.ChartObjects("Chart13").Active With ActiveChart.Parent .Height = 250 'use desired height in points .Width = 350 'use desired width in poits .Left = (Windows(ActiveWorkbook.Name).Width - .Width) / 2 .Top = (Windows(ActiveWorkbook.Name).Height - .Height) / 2 End With End Sub -----Original Message----- Phil, Use ActiveSheet.ChartObjects("Chart13").Activate -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "Phil Hageman" wrote in message ... In the following code, I receive a compile error: Sub or Function not defined. In the fifth line, "ChartObjects" is highlighted. Can someone help me clear this problem? Sub GoToMetricsA1() ' GoToMetricsA1 Macro Sheets("Metrics").Select Range("A1").Select ChartObjects("Chart13").activate With ActiveChart.Parent .Height = 250 ' use desired height in points .Width = 350 ' use desired width in points .Left = (Windows (ActiveWorkbook.Name).Width - _ .Width)/2 .Top = (Windows (ActiveWorkbook.Name).Height - _ .Height)/2 End With End Sub . . . |
Positioning
I can't fix it if it works for me.
-- Regards, Tom Ogilvy "Phil Hageman" wrote in message ... Yes, the chart is smaller than the screen. I made the height 550 and width 650, so I sized it smaller than the screen. The code has /2 at the end of the coding line. I've tried changing them, but the chart remains in the upper left corner. -----Original Message----- For me it was centered on the screen. Is the chart smaller than the visible window? Perhaps you need to check the values you are passing to top and left to see what is calculated. -- Regards, Tom Ogilvy "Phil Hageman" wrote in message ... Thanks for the help, Tom. Chip pointed to two mistakes I made - carelessness on my part. Could you answer a question: I need to manipulate the screen position of the chart. As this code works, the chart is positioning in the upper left corner. Thanks, Phil -----Original Message----- ActiveSheet.ChartObjects("Chart13").Active should be ActiveSheet.ChartObjects("Chart13").Activate or ActiveSheet.ChartObjects("Chart13").Select -- Regards, Tom Ogilvy "Phil Hageman" wrote in message ... Thanks for your help Chip - appreciate your time. I entered the change, per the following, and received Run- time error '1004': "Unable to get the ChartObjects property of the Worksheet class." The ActiveSheet... line is highlighted yellow. Did I put this in wrong? Thanks, Phil Sub GoToMetricsA1() ' GoToMetricsA1 Macro Sheets("Metrics").Select Range("A1").Select ActiveSheet.ChartObjects("Chart13").Active With ActiveChart.Parent .Height = 250 'use desired height in points .Width = 350 'use desired width in poits .Left = (Windows(ActiveWorkbook.Name).Width - .Width) / 2 .Top = (Windows(ActiveWorkbook.Name).Height - .Height) / 2 End With End Sub -----Original Message----- Phil, Use ActiveSheet.ChartObjects("Chart13").Activate -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "Phil Hageman" wrote in message ... In the following code, I receive a compile error: Sub or Function not defined. In the fifth line, "ChartObjects" is highlighted. Can someone help me clear this problem? Sub GoToMetricsA1() ' GoToMetricsA1 Macro Sheets("Metrics").Select Range("A1").Select ChartObjects("Chart13").activate With ActiveChart.Parent .Height = 250 ' use desired height in points .Width = 350 ' use desired width in points .Left = (Windows (ActiveWorkbook.Name).Width - _ .Width)/2 .Top = (Windows (ActiveWorkbook.Name).Height - _ .Height)/2 End With End Sub . . . |
All times are GMT +1. The time now is 05:32 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com