CopyPicture method of range class failed using RangeName

All,

I have a worksheet where I am cycling through some pivot tables and
copying a range defined by a range name to an output sheet.  The range
being copied includes a chart and a few rows of cells.  I keep getting
a
Run-Time Error '1004':
CopyPicture method of range class failed

I believe the syntax is correct because if I use error code and use
resume it will continue after 0 to <15 tries?

Anyone have any experience with this issue?

I have tried both options below:
Range(strRangeName).CopyPicture Appearance:=xlScreen,
Format:=xlPicture

Worksheets(SourceSheetName).Range(strRangeName).CopyPicture
Appearance:=xlScreen, Format:=xlPicture
1
CG
1/13/2010 4:46:35 PM
excel.programming 6508 articles. 2 followers. Follow

4 Replies
6543 Views

Similar Articles

[PageSpeed] 6

For debugging in the VBE first i would add a watch for strRangeName.
Sounds like that name sometimes isn't correct.
0
minimaster
1/13/2010 4:58:07 PM
I assume you are using Excel 2007. CopyPicture with the Format:=xlPicture 
argument fails with Range and Chart objects. I filed this as a bug quite a 
while ago together with a workaround, namely use Format:=xlBitmap

It seems there's no chance of it being fixed.

Regards,
Peter T

"CG" <cgjunk@gmail.com> wrote in message 
news:3539cd9d-545f-4c43-96e7-9f7f96994094@q4g2000yqm.googlegroups.com...
> All,
>
> I have a worksheet where I am cycling through some pivot tables and
> copying a range defined by a range name to an output sheet.  The range
> being copied includes a chart and a few rows of cells.  I keep getting
> a
> Run-Time Error '1004':
> CopyPicture method of range class failed
>
> I believe the syntax is correct because if I use error code and use
> resume it will continue after 0 to <15 tries?
>
> Anyone have any experience with this issue?
>
> I have tried both options below:
> Range(strRangeName).CopyPicture Appearance:=xlScreen,
> Format:=xlPicture
>
> Worksheets(SourceSheetName).Range(strRangeName).CopyPicture
> Appearance:=xlScreen, Format:=xlPicture 


0
Peter
1/13/2010 8:28:09 PM
On Jan 13, 2:28=A0pm, "Peter T" <peter_t@discussions> wrote:
> I assume you are using Excel 2007. CopyPicture with the Format:=3DxlPictu=
re
> argument fails with Range and Chart objects. I filed this as a bug quite =
a
> while ago together with a workaround, namely use Format:=3DxlBitmap
>
> It seems there's no chance of it being fixed.
>
> Regards,
> Peter T
>
> "CG" <cgj...@gmail.com> wrote in message
>
> news:3539cd9d-545f-4c43-96e7-9f7f96994094@q4g2000yqm.googlegroups.com...
>
> > All,
>
> > I have a worksheet where I am cycling through some pivot tables and
> > copying a range defined by a range name to an output sheet. =A0The rang=
e
> > being copied includes a chart and a few rows of cells. =A0I keep gettin=
g
> > a
> > Run-Time Error '1004':
> > CopyPicture method of range class failed
>
> > I believe the syntax is correct because if I use error code and use
> > resume it will continue after 0 to <15 tries?
>
> > Anyone have any experience with this issue?
>
> > I have tried both options below:
> > Range(strRangeName).CopyPicture Appearance:=3DxlScreen,
> > Format:=3DxlPicture
>
> > Worksheets(SourceSheetName).Range(strRangeName).CopyPicture
> > Appearance:=3DxlScreen, Format:=3DxlPicture

Peter,

I am using XL 2003.  I believe the problem was I had a subroutine that
used some small arrays of objects and I was not setting them to
Nothing at the end of the routine.  They were called several times and
the more the code ran the bigger the problem got.  Does that make
sense to anyone?

CG
0
CG
1/22/2010 1:15:12 PM
Both versions of the code you originally posted should work fine in Excel 
2003 or earlier, assuming you are returning a valid range object in the 
first part before you get to .CopyPicture

If your object variable arrays are declared at procedure level there is no 
need to explicitly destroy them, they will loose scope get cleaned up very 
efficiently with VBA's garbage collection.

It's a good idea to destroy module level objects when not needed with Set 
myObjVar = Nothing, however using them repeatedly should not cause any 
problems.

Regards,
Peter T


"CG" <cgjunk@gmail.com> wrote in message
> Peter,

> I am using XL 2003.  I believe the problem was I had a subroutine that
> used some small arrays of objects and I was not setting them to
> Nothing at the end of the routine.  They were called several times and
> the more the code ran the bigger the problem got.  Does that make
> sense to anyone?

> CG 


0
Peter
1/22/2010 4:17:50 PM
Reply:

Similar Artilces:

can't use the click-to-send in a recieved e-mail
Hi All, Using Microsoft outlook (office) Did something (installed and removed Photodex Gold) - trial time ran out. Created one file, removed the program (uninstalled). The problem is: When I 'click' on an e-mail address in a message that I received, the photodex program opened instead of opening the mail to indow. - So I removed the photodex program. Now I just found the show that I created - I deleted it . (i t ended in an '.exe'... ) NOW when I try "click to send" from inside an e-mail that I received, the 'Locate Link Browser opens up with the ".exe...

Online Update seems to fail
In my Portfolio section, I choose to "Update Stocks Online," and although the screen seems to go through its usual machinations of calling and completing the contact, the updates do not occur. My last update was 12/6; I've been able to update critical prices online by clicking through to the stock reports, and then entering prices manually. To my knowledge, no new software or protection was put onto my computer; no changes in settings that I'm aware of; I've not changed ISP; rebooted repeatedly; about out of the usual "largely computer illiterate" opti...

CopyPicture from Excel Range to Power Point
Hi, I've designed a VBA routine which copies an Excel range to Power Point. The selected range is copied with "CopyPicture". It works OK apart from that some times selected columns most to right in the range will not be visible in the pasted picture in Power Point. It can vary depending on which user runs the routine. Before CopyPicture only visible cells are selected. Some columns in the range are grouped and not visible. e.g in a range from column A - Y 12 columns are selected as visible columns. Thanks in advance for any help. Mats ...

Debug Assertion Failed #4
Hi, when i create a new second form and add in FileOnPrint and FileOnPrintPreview command from the MFC classwizard. On the Constructor, i added the following code: void CProduct::OnFilePrint() { // TODO: Add your command handler code here CFormView::OnFilePrint() ; // code added } when execute and press the print button to test whether it is working or not, I got the following error: Debug Assertion Failed. File: viewprnt.ccp Line: 161 How do I remedy the problem. Thanks. Newbie & Noobie wrote: > Hi, > when i create a new second form and add in FileOnPrint and > Fi...

IsNotEmpty Range
Hello...I have a little vb code tht I am trying to get to work with a range of cells. Basically if any of the cells in the range are empty it should return a message. the code works if a single cell (such as D14) is used but not when I put the range (such as D14:D63). Anyone have any ideas as to how I can get this to work without listing each cell individually? here is what I hve so far: Private Sub Sr_Mgr_Click() If IsEmpty(Sheets("Sr-Area Manager").Range("D14:D63")) Then r = MsgBox("You are missing a Move-In Date. Move-In Dates are a ...

Macro to select only cells within the range that contain data
Thanks to this board, I now can sort my text+numerical values the way I would like, with Excel Ignoring all characters but the numbers. Now, this data is in a column that contains 43 entries. In the future there may be more entries, but my current macro will only select the 43 entries (I made the macro using the macro builder) and selected only the cells with data. If I select the additional cells, the sort puts the blanks at the top of the form and this is not acceptable. (We have no one else at work that will be able to change the macro, if I'm not there and our list increases) I ne...

the server does not support the required HTTP methods 0x800CCC3E
I just started to get this error. ALso, I can not create more then 1 Homail account. When I do, only 1 account does Outlook pull & syn information from. Please help. What version of Outlook do you have? Outlook 2002 can only have one Hotmail account - Outlook 2003 allows multiple accounts. As to the error you're getting, you probably have a proxy server between you and Hotmail that doesn't understand the HTTP/DAV protocol used by Hotmail. Contact your network adminstrator (if the problem is occurring at work) or your ISP (if it happens at home) and ask them to upgrade to a pro...

problem using xsl with hebrew
Hi. i need help. i can`t use xsl to transform an xml to html using asp.net. when the xml and the xsl are in english it works fine. the problem began when the xml ans xsl have words in hebrew. i put the next sentence in the start of the xml and the xsl: <?xml version="1.0" encoding="windows-1255"?> and it did not solved the problem. here is my 1. the xml file : <?xml version="1.0" encoding="windows-1255"?> <FUN> <CATEGORY TYPE="&#1502;&#1493;&#1494;&#1497;&#1488;&#1493;&#1504;&#1497;&a...

CopyPicture ?????
What on earth is happening with th code below?????? The code works fine, copying a chartobject and pasting it into a new location. The problem is that while the chart area is the same size, only two thirds of the image is copied. I will say that I have stretched the plot area of the original, it itself does not behave strangely. I have no idea what the problem is, does any one else? Code Snippet: ThisWorkbook.Activate Worksheets("Summary").Activate Range("A30").Select ActiveSheet.ChartObjects("First Chart").CopyPicture xlScreen, xlBitmap Workbooks(Tar...

Using Custom Mapped fields when importing in Outlook 2002
I am trying to import a *.csv file from Excel into contacts of Outlook 2002. I have created a custome made contact form and made it my default, but when trying to map the fields within the import wizard, my custom made contact form is not used to map to. Any ideas on how to make the mapped to reflect my user defined fields? Thanks! ...

XmlSerializer with XSDObjectGenerator generated class
Hi, I need to send data to service via XML. This service gave me a schema that you could find in http://www.forum-datenaustausch.ch/fr/pharmacyinvoicerequest_400.xsd . I generated objects with this nice tool XSDObjectGenerator. When I tried to Serialize my data's, I had exception (InnerException) "There was an error reflecting field '__prolog'.". Here is my test code: Dim fStream2 As New FileStream("C:\Temp\request.xml", FileMode.Create) Dim request As New request() request.invoice.detail.services.record_drugCollection.Add().amount = 111.112 Dim ser As Ne...

Mandatory Password Change using OWA
Is there a way of making OWA mandate a password change. Like the Windows login password mandate that says you have to change your password in order to log in? I figured it would do that automatically. Instead it's locking my clients out once their password expires and I get an angry phone call. I have Exchange 2003 SP2 on a Windows 2000 SP4 Server box. Thanks in advance for any input. Michael On Wed, 27 Sep 2006 21:31:08 GMT, nospam@noway.com wrote: >Is there a way of making OWA mandate a password change. > >Like the Windows login password mandate that says you have to cha...

Cannot change cost basis calculation method
The online help for Money 2003 says that I should be able to change the method used to calculate the cost basis of a mutual fund. However, when I go to the details page for a mutual fund, no such option exists. Is this a bug in the documentation, or the program? In microsoft.public.money, Paul Galbraith wrote: >The online help for Money 2003 says that I should be able to change the >method used to calculate the cost basis of a mutual fund. However, when I >go to the details page for a mutual fund, no such option exists. Is this a >bug in the documentation, or the program? ...

Indexing outlook 2000 mail with google desktop fails
Hello, I try to index outlook 2000 mail with google desktop search engine without success. My system: XP SP1. I have both outlook express and outlook 2000 installed, outlook 2000 is my default mail program. I tried all solutions recommended by google: 1)Outlook is opened during initial and further search. 2)add-in for Desktop Search: I am unable to display 'Google Desktop Search Outlook Addin.' item as requested when applying the recommended procedure: ..Open Outlook. ..Go to 'Tools' > 'Options' > 'Other' > 'Advanced Options...' > 'Add-I...

Range CopyPicture()
Hi, I'm working on an app which i need to copy a range of cells which is programatically generated using the Excel object model. I want to be able to select the output range which consists of charts and cells making up a table. I'm using the CopyPicture() method of Range which i had woring once to copy the charts and cells combination into word. Having run this again it won't pull across the charts now. The areas where these are meant to go are just blank. Has anyone experienced this before and could maybe give me some information on how to resolve this. I know it can be d...

looking for the method like postmessage in win32.
hi everyone. i'm working on vs2003 and C#. it is windows application that i'm creating. so i have a form. i created worker-thread and the worker thread calls back the callback- method in the form. in the callback-method, i'm going to implement the code that adds a TabPage object to TabControl that's created by main-thread. so i receive the exception that says "dont add the control to another they are created by the diffrent thread." or something like that. i need something like the PostMessage in win32. to order the main-thread to perform the job on...

CopyPicture Colors to PowerPoint
Hi I am trying to automate the copying of charts from Excel 97 to a PowerPoint 97 slideshow. On some machines, the colours do not get copied across correctly. I have tried various combinations of the parameters for CopyPicture, but none seem to get around the problem. Does the colour palette have to be copied across also? If so, how is it achieved? This is a snippet of my code... Set nextChart = nextWorksheet.ChartObjects(1).chart Call nextChart.CopyPicture(xlScreen, xlPicture, xlScreen) Set ppSlide = ppPresentation.Slides.Add(newSlidePosition, ppLayoutBlank) Set ...

Setting a Default Print Range
I am using Microsoft Project 2002 and I was wondering if I can set a default range in the Gantt Chart. Rather than print all the chart I would like to print out the first ten or so columns on the left hand side of the Gantt Chart. Can this be set as a default as my colleagues forget to check it before they print it so it is wasting a lot of paper? TIA That is a project by project setting in File > Page Setup > View. If you set it that way in your templates, in theory, it should work - however if they create projects without templates, I am not sure how you would set it a...

Comparing two data ranges for differences.
Is there any easy way to take two ranges of data and compare their contents for differences. In particular im working with a rather large list of domains and attempting to compare two columns to determine what websites are different between the two. I've tried conditional formating, wont let you use a range as the target and tried searching for a formula to use without any luck. Any suggestions would be useful or even if someone could point me in the right direction. ...

Error (0x80004005) operation failed
Anyone seen this when using Outlook XP with "WORD AS EMAIL EDITOR" connecting to Exchange 5.5 server? The email came in...in HTML format, from another internal users...the message said something like OUTLOOK CAN'T DISPLAY SOME SCRIPTS in the email - when replying it give the (0x80004005) operation failed after you hit send and the SEND/RECEIVE box pops up. Any ideas? I removed "word as email editor" and it worked fine. Of course the user insists to use "word as email editor" because of the extra features but it has always been a little flaky. Let...

Range Slider control
Hi, I'm looking for a control similar to the slider control, that allows the user to enter a minimum and maximum value. At this moment my users have to enter both values via simple edit controls, but it would be much nicer if they would have a kind of range-slider control. Apparently, the standard Windows/MFC Slider control is limited to selecting 1 value, and I cannot find a way to add a second 'thumb' to it to allow the user to select a second value. I looked at commercial packages (CodeJock, BCG) but they also don't have this kind of control. I found some controls that se...

Using Primopdf
I asked earlier about opening a Publusher 2003 file which will not open with my pc software (old Publisher 2000, Word 2000, Adobe Reader 7.0) I was advised to down load PrimoPDF, which I did, but I don't know how to convert the Publisher 2003 file to a pdf format if I can't otherwise first open the file. How do I use primopdf to convert this file so it will open in Adobe Reader? pdf creators act like printer drivers...you print the document to the pdf creator. You still have the original problem of opening Pub 2003 and then printing to the pdf creator...but, I'm sure some...

copy pointer CSocket class
Hi MFC Gurus, I have some problems which I need to copy a pointer of class object (derived from CSocket). I am using operator = so that I could use temp1=temp; //both are objects from the same class. so that when temp is destroyed, I would still have temp1 data. however, this is not working since when I use temp1->Send(data, size); it is not invoking anything in client appl. Thank you. Regards, Rehmet Code: class mysocket : public CSocket { public: CDialog *dlg; CString name; mysocket(); virtual ~mysocket(); void setparent(CDialog *dlg); virtual void OnAccept(int errcode); ...

Text Method "Overwrite" problem
I'm having a problem with Overwrite=True when using the Text Method to insert text into a comment in my Excel worksheet. I can insert text into my comment at the specified character position, no problem. However it doesn't seem to matter if I set Overwrite to true or false, the text is always inserted rather than overwriting existing text. Here is the description of the method, followed by my code: Text Method Sets comment text. Syntax expression.Text(Text, Start, Overwrite) expression Required. An expression that returns a Comment object. Text Optional Variant. The text t...

Lookup / Array Range / find the value
I have seen similiar examples but not that were not using exact matches to retrieve data. This seems simple and maybe I am over thinking but I have been unable to crack this nut. I have a table where the first tier sales runs between 0 and 20k and awards 1K commission. I want to be able to enter the salse result for various team members and obtain the correct commission amount based on their sales for the period. How should I complete the commission formula for this process? Sales Value Start Sales Value Stop Commission $0 $20,000 $1,000.00 $...