Skip to content

Excel Range.CopyPicture not supported? #582

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
EMIjess opened this issue Nov 12, 2016 · 3 comments · Fixed by #1707
Closed

Excel Range.CopyPicture not supported? #582

EMIjess opened this issue Nov 12, 2016 · 3 comments · Fixed by #1707
Milestone

Comments

@EMIjess
Copy link

EMIjess commented Nov 12, 2016

Per Microsoft, Range has a method CopyPicture() - https://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel.range.copypicture.aspx

When testing in xlwings, using:

import xlwings as xw # for Excel interactivity
wb = xw.Book("test.xlsx")
mysheet = wb.sheets('Sheet1')
thisrange = mysheet.range("a1:b3")
pic = thisrange.CopyPicture('xlPicture', 'xlScreen')

I get this error

python testing.py
Traceback (most recent call last):
  File "testing.py", line 37, in <module>
    pic = thisrange.CopyPicture('xlPicture', 'xlScreen')
AttributeError: 'Range' object has no attribute 'CopyPicture'

Perhaps there is another solution for taking a screenshot of a worksheet or range within xlwings, but I did not see it in the docs.

@fzumstein
Copy link
Member

It's not natively implemented, but as usual, you can always get it by following the instructions here:
http://docs.xlwings.org/en/stable/missing_features.html

In your case that is

import xlwings as xw
from xlwings.constants import CopyPictureFormat, PictureAppearance

xw.Range('A1:B2').api.CopyPicture(PictureAppearance.xlScreen,
                                  CopyPictureFormat.xlPicture)

@camiloos618
Copy link

camiloos618 commented Aug 23, 2019

I have a problem in VBA with Range.CopyPicture method. Is this problem solved in xlwings? CopyPicture randomly generates error in VBA, please try this simple test in your VBA:

Sub test1()
    Dim x1 As Long
    For x1 = 1 To 100
        Range("A1:A1").CopyPicture
    Next x1
    MsgBox "Test completed !!"
End Sub

I wonder if using xlwings will solve my problem. I design controlling reports that are sent by e-mail and I sometimes need to attach an image from a range of cells.

@fzumstein
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants