Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Unselect all selected areas in all sheets | Excel Discussion (Misc queries) | |||
ActiveWindow.VisibleRange.Width - Is this the correct code | Excel Programming | |||
Passing chartobject as a parameter to sub | Excel Programming | |||
ChartObject Name Restricion or Excel Bug | Excel Programming | |||
ChartObject index | Excel Programming |