• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Create jpg (about dynamic range)

Villalobos

Active Member
Hello,

I would need your help regarding jpg creating. My question would be that: how is it possible to set the range until: ("A1:AP" & Lastrow)? In my file the content of this range is changing each day therefore I would like to handle "dynamically"... somehow.

This the code what I have now:

Code:
Sub createJpg(Namesheet As String, nameRange As String, nameFile As String)
Dim Plage As Variant
Dim Lastrow As Long
  ThisWorkbook.Activate
  Worksheets("Evaluation").Activate
  Set Plage = ThisWorkbook.Worksheets("Evaluation").Range("A1:AP" & Lastrow)
  Plage.CopyPicture
  With ThisWorkbook.Worksheets("Evaluation").ChartObjects.Add(Plage.Left, Plage.Top, Plage.Width, Plage.Height)
  .Activate
  .Chart.Paste
  .Chart.Export Environ$("temp") & "\" & nameFile & ".jpg", "JPG"
  End With
  Worksheets("Evaluation").ChartObjects(Worksheets("Evaluation").ChartObjects.Count).Delete
  Set Plage = Nothing
End Sub

but I receive Application-defined or Object-defined error msg at this line:

Code:
 Set Plage = ThisWorkbook.Worksheets("Evaluation").Range("A1:AP" & Lastrow)

After this code I have another routine which is attach this jpg to email body.

Thanks in advance your reply!
 

Hi !

You forgot to initialize the Lastrow variable ‼
Copy / Paste is not coding …

Instead of using a variable,
see in VBA help UsedRange and CurrentRegion
 
Hi Marc L,

Thank you for your attention, could you please give me bit more direction, my knowledge is pour regarding this.
 

You already had demonstrations on your previous thread in this forum
and in another one !

If you keep LastRow variable, how do you calculate it ?
 
Back
Top