• 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.

Running macro slows down entire workbook

Bricklin

New Member
I have a button that runs a macro to import the last image saved to the clipboard. The code is below. It works and puts the image in the proper position but after executing the entire workbook slows to a crawl. Is there a way to fix this???

Thanks


Code:
Sub Import_Image()

Dim p As Picture
With Selection
    Set p = .Parent.Pictures.Paste
    p.Top = 190
    p.Left = 655
    p.Width = 275
End With
End Sub
 
Last edited by a moderator:

Forum rule : use code tags !

Easy logic (just burning a couple of neurones) : as the procedure ends,
it can not be the issue slowing down entire workbook

So first see once image removed and take a glance at its properties …
 
If I remove the image, the spreadsheet runs fine. It only slows down if the image is there. There is a dramatic difference in speed.
 

Well, what about its properties ?

Did you ever think to resize it with your favorite picture software ?
Or maybe with the compress icon within the Excel picture toolbar …
 
Is there a way to automate that step? Trying to avoid complicating the process if I don'y have to. Others are using the sheet and I'm trying to keep user interaction to a minimum.

The way it works now is they click on the image from a .pdf file generated from a web based program. Once they click on it -they save it to the clipboard. Then they click on the import button that I created on the spreadsheet and a macro imports, sizes, and positions it automatically.

Just trying to keep it as simple as possible.
 

But internal size stays to 100% insane of original !

As yet written :

• try the compress icon within the Excel picture toolbar.

• Do not directly download image to worksheet
but resize it on local hard drive using a picture software …
 
One final challenge..

I actually have 2 sources for the imported files. One image is smaller than the other but I want them to import at the same size.

Is there a way within a macro to check the size and do a "if/then" to change the amount of scaling? an example would be "if the height of the original image is over 5" scale to 16% else scale to 80%?


current macro:
Sub Import_Image()

Range("N11:p18").Select
ActiveSheet.PasteSpecial Format:="Bitmap", Link:=False, DisplayAsIcon:= _
False
Selection.ShapeRange.ScaleHeight 0.16, msoFalse, msoScaleFromTopLeft
Range("F20").Select
End Sub

Really appreciate the help on this forum!!!!
 
Back
Top