Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 160
Default 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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 160
Default 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

..
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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

.



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 160
Default 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

.



.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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
.



.



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Run-time Error '1004'

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

.



  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 160
Default 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

.



.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Compile VBA code? (Passwording too weak a protection scheme?) [email protected] Excel Discussion (Misc queries) 1 August 20th 06 04:57 PM
help with this error-Compile error: cant find project or library JackR Excel Discussion (Misc queries) 2 June 10th 06 09:09 PM
How do I get rid of "Compile error in hidden module" error message David Excel Discussion (Misc queries) 4 January 21st 05 11:39 PM


All times are GMT +1. The time now is 10:55 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"