no, you would have to do it by combining the chart areas if that can be done as it can with ranges
else, can you set the copy destination then just copy the 2 areas
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case. Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
i have never tried with chart areas, but to combine 2 (or more) ranges, use union
vb Code:
set myrange = union(range("A4:J19"),range("L12:X99"))
myrange.copy
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case. Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
But if you do this manually, you select the first chart then hold down Ctrl buttom and select the second chart. Then you can copy and paste two charts. Can't I do this in VB?
i am sure you can if you can do manually, the chart area should just be another range as i posted above
i try to never use select when i write code as i can have problems, especially from outside programs, so would combine without selecting, then copy
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case. Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
But how can I do this from VB. I have two OLE with MsGraph in each one of them.
Copy a chart from one OLE is no problem. But how can I copy both charts at the same time to clipboard?
Copy one chart I do like this
VB Code:
Dim objGraph As Object
Clipboard.Clear
Set objGraph = Me.OLE1.object
objGraph.ChartArea.Copy
Set objGraph = Nothing
Last edited by Pirre001; Jan 7th, 2008 at 02:17 PM.
i believe that is like trying to work in 2 instances of excel, so i don't believe you would be able to do it, the only way i can think of is to copy the first, paste it before of after the second, then copy both, or use a temporary workspace to copy both to, before copying together
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case. Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
use an empty sheet in one of your workbooks?
add a new sheet if need be delete when finished
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case. Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
yes, but you already have workbooks open that you can work with
a range is copied as a string, so it can just be returned into a string variable, but if you want to position one range against another or anything like that then putting it into another sheet makes sense, but if you ara happy to just have one followed by the second then you could just add both to string variables and manipulate the strings
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case. Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
Dim strtxt As String ' delcare as global at top of form or module
Private Sub Command1_Click() 'get 1st clipboard object
strtxt = Clipboard.GetText
End Sub
Private Sub Command2_Click() 'get 2nd clipboard object
strtxt = strtxt & vbNewLine & Clipboard.GetText
Clipboard.SetText = strtxt ' copy combined to clipboard
End Sub
as you are selecting the source by code, you will not need to use separate subs to combine
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case. Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case. Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
i tried this and it basically works, but you will have to do some adjustments to the picture box sizes, to get the image the way you want it
you will need 3 pictureboxes, though you could probably use stdpictures for 2
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case. Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
i didn't try to get the sizes right, but you can try setting autosize to true for all the pictureboxes, all the pictureboxes could be set to visible to false, a you don't need to see them
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case. Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
i don't know that i kept it, i will have to redo a bit later
(close, don't save)
here it is, works perfectly............... lol
only 2 pictureboxes required, picture2 needs autosize
Last edited by westconn1; Jan 27th, 2008 at 06:36 PM.
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case. Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete