Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 .. |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 . |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 . . |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 . . |
#8
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 . . |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Compile VBA code? (Passwording too weak a protection scheme?) | Excel Discussion (Misc queries) | |||
help with this error-Compile error: cant find project or library | Excel Discussion (Misc queries) | |||
How do I get rid of "Compile error in hidden module" error message | Excel Discussion (Misc queries) |