Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 92
Default How unselect? Want to run ActiveWindow.VisibleRange but have Chartobject selected

I move charts from sheet2 to sheet1 and back again with these two
procedures. With a chartobject named "CHT5" in sheet2 you should be
able to test the code. Error come on line "Set rng =
ActiveWindow.VisibleRange" and I guess it is because activewindow is
the window the chartobject is within and it doesn't have ".
VisibleRange".

The row "Sheet2.ChartObjects("CHT5").Chart.Location
Whe=xlLocationAsObject, _ Name:=ActiveSheet.Name" seem to always
select the chartobject of some reason ...

Therefo How can I unselect the chartobject window to the ordinary
range selection on the worksheet and be able to run the code? Excel
seems to need something always selected.

I don't want to select A1 or something but want to have the last range
selection still intact after "MoveBackChart" is used!


Sub InsertChartMiddle()
Dim picWd As Integer
Dim picHt As Integer
Dim rng As Range
If Sheet3.Range("A1").Value = 0 Then
Sheet2.ChartObjects("CHT5").Chart.Location
Whe=xlLocationAsObject, _ Name:=ActiveSheet.Name

'Find middle of window
ActiveSheet.Select
Set rng = ActiveWindow.VisibleRange ' ERROR
cTop = rng.Top + 0.5 * rng.Height
cWidth = rng.Left + 0.5 * rng.Width

'Notify the Chartobject shows
Sheet3.Range("A1").Value= 1
End If
End Sub

Sub MoveBackChart()
On Error Resume Next
ActiveSheet.ChartObjects("CHT5").Chart.Location
Whe=xlLocationAsObject, Name:="Sheet2"
Sheet3.Range("A1").Value = 0
End Sub

Grateful to all help

Regards,
tskogstrom

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default How unselect? Want to run ActiveWindow.VisibleRange but have Chartobject selected

Sheet2.ChartObjects("CHT5").Chart.Location
Whe=xlLocationAsObject, _
Name:=ActiveSheet.Name"
ActiveCell.Select

--
Regards,
Tom Ogilvy


"tskogstrom" wrote in message
oups.com...
I move charts from sheet2 to sheet1 and back again with these two
procedures. With a chartobject named "CHT5" in sheet2 you should be
able to test the code. Error come on line "Set rng =
ActiveWindow.VisibleRange" and I guess it is because activewindow is
the window the chartobject is within and it doesn't have ".
VisibleRange".

The row "Sheet2.ChartObjects("CHT5").Chart.Location
Whe=xlLocationAsObject, _ Name:=ActiveSheet.Name" seem to always
select the chartobject of some reason ...

Therefo How can I unselect the chartobject window to the ordinary
range selection on the worksheet and be able to run the code? Excel
seems to need something always selected.

I don't want to select A1 or something but want to have the last range
selection still intact after "MoveBackChart" is used!


Sub InsertChartMiddle()
Dim picWd As Integer
Dim picHt As Integer
Dim rng As Range
If Sheet3.Range("A1").Value = 0 Then
Sheet2.ChartObjects("CHT5").Chart.Location
Whe=xlLocationAsObject, _ Name:=ActiveSheet.Name

'Find middle of window
ActiveSheet.Select
Set rng = ActiveWindow.VisibleRange ' ERROR
cTop = rng.Top + 0.5 * rng.Height
cWidth = rng.Left + 0.5 * rng.Width

'Notify the Chartobject shows
Sheet3.Range("A1").Value= 1
End If
End Sub

Sub MoveBackChart()
On Error Resume Next
ActiveSheet.ChartObjects("CHT5").Chart.Location
Whe=xlLocationAsObject, Name:="Sheet2"
Sheet3.Range("A1").Value = 0
End Sub

Grateful to all help

Regards,
tskogstrom



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 92
Default How unselect? Want to run ActiveWindow.VisibleRange but have Chartobject selected

Hi Tom,
Thank you for your help.

On line Activecell.select, I get Error "Object variable och With block
not set" or something like that.

Ideas?

regards
tskogstrom

Tom Ogilvy skrev:

Sheet2.ChartObjects("CHT5").Chart.Location
Whe=xlLocationAsObject, _
Name:=ActiveSheet.Name"
ActiveCell.Select

--
Regards,
Tom Ogilvy


"tskogstrom" wrote in message
oups.com...
I move charts from sheet2 to sheet1 and back again with these two
procedures. With a chartobject named "CHT5" in sheet2 you should be
able to test the code. Error come on line "Set rng =
ActiveWindow.VisibleRange" and I guess it is because activewindow is
the window the chartobject is within and it doesn't have ".
VisibleRange".

The row "Sheet2.ChartObjects("CHT5").Chart.Location
Whe=xlLocationAsObject, _ Name:=ActiveSheet.Name" seem to always
select the chartobject of some reason ...

Therefo How can I unselect the chartobject window to the ordinary
range selection on the worksheet and be able to run the code? Excel
seems to need something always selected.

I don't want to select A1 or something but want to have the last range
selection still intact after "MoveBackChart" is used!


Sub InsertChartMiddle()
Dim picWd As Integer
Dim picHt As Integer
Dim rng As Range
If Sheet3.Range("A1").Value = 0 Then
Sheet2.ChartObjects("CHT5").Chart.Location
Whe=xlLocationAsObject, _ Name:=ActiveSheet.Name

'Find middle of window
ActiveSheet.Select
Set rng = ActiveWindow.VisibleRange ' ERROR
cTop = rng.Top + 0.5 * rng.Height
cWidth = rng.Left + 0.5 * rng.Width

'Notify the Chartobject shows
Sheet3.Range("A1").Value= 1
End If
End Sub

Sub MoveBackChart()
On Error Resume Next
ActiveSheet.ChartObjects("CHT5").Chart.Location
Whe=xlLocationAsObject, Name:="Sheet2"
Sheet3.Range("A1").Value = 0
End Sub

Grateful to all help

Regards,
tskogstrom


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default How unselect? Want to run ActiveWindow.VisibleRange but have Chartobject selected

sound like an implementation problem on your part. Activecell is defined
and set by Excel/VBA.

--
Regards,
Tom Ogilvy

"tskogstrom" wrote in message
oups.com...
Hi Tom,
Thank you for your help.

On line Activecell.select, I get Error "Object variable och With block
not set" or something like that.

Ideas?

regards
tskogstrom

Tom Ogilvy skrev:

Sheet2.ChartObjects("CHT5").Chart.Location
Whe=xlLocationAsObject, _
Name:=ActiveSheet.Name"
ActiveCell.Select

--
Regards,
Tom Ogilvy


"tskogstrom" wrote in message
oups.com...
I move charts from sheet2 to sheet1 and back again with these two
procedures. With a chartobject named "CHT5" in sheet2 you should be
able to test the code. Error come on line "Set rng =
ActiveWindow.VisibleRange" and I guess it is because activewindow is
the window the chartobject is within and it doesn't have ".
VisibleRange".

The row "Sheet2.ChartObjects("CHT5").Chart.Location
Whe=xlLocationAsObject, _ Name:=ActiveSheet.Name" seem to always
select the chartobject of some reason ...

Therefo How can I unselect the chartobject window to the ordinary
range selection on the worksheet and be able to run the code? Excel
seems to need something always selected.

I don't want to select A1 or something but want to have the last range
selection still intact after "MoveBackChart" is used!


Sub InsertChartMiddle()
Dim picWd As Integer
Dim picHt As Integer
Dim rng As Range
If Sheet3.Range("A1").Value = 0 Then
Sheet2.ChartObjects("CHT5").Chart.Location
Whe=xlLocationAsObject, _ Name:=ActiveSheet.Name

'Find middle of window
ActiveSheet.Select
Set rng = ActiveWindow.VisibleRange ' ERROR
cTop = rng.Top + 0.5 * rng.Height
cWidth = rng.Left + 0.5 * rng.Width

'Notify the Chartobject shows
Sheet3.Range("A1").Value= 1
End If
End Sub

Sub MoveBackChart()
On Error Resume Next
ActiveSheet.ChartObjects("CHT5").Chart.Location
Whe=xlLocationAsObject, Name:="Sheet2"
Sheet3.Range("A1").Value = 0
End Sub

Grateful to all help

Regards,
tskogstrom




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
Unselect all selected areas in all sheets SiriS Excel Discussion (Misc queries) 2 January 20th 06 08:36 AM
ActiveWindow.VisibleRange.Width - Is this the correct code StevenS Excel Programming 1 October 15th 05 06:34 AM
Passing chartobject as a parameter to sub David Cohen Excel Programming 0 September 21st 05 09:58 PM
ChartObject Name Restricion or Excel Bug Gaston Excel Programming 0 February 14th 05 05:51 PM
ChartObject index Claude Excel Programming 3 January 30th 04 09:33 PM


All times are GMT +1. The time now is 12:30 AM.

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

About Us

"It's about Microsoft Excel"