Trouble getting graphs copied from stability into word through VBA Design.CopyImage

Hi there,

I'm trying to automate data exchange from Maxsurf Stability to Word for reporting. Now specifically I'm running a large angle stability analysis, and trying to get a copy of the stability curve from Maxsurf Stability into my Word report. There's the handy .Design.CopyImage method which should do exactly that, however I don't get consistent results. My VBA code is as follows

hmApp.Design.CopyImage View:=6, Width:=700, Height:=450
LASgraph.Collapse Direction:=wdCollapseEnd
LASgraph.Paste

Now the CopyImage method requires a width and height to be specified. Height I found is just scaling the full image of the graph to the specified height, which is good. But width somehow crops the image, instead of scaling it. So through trial and error I found the width that corresponded with the full graph picture, which initially resolved the issue. However when I adjust the size of the graph display in stability (e.g. maximize it), this changes the size of the initial bitmap apparently so that I'm again stuck with only half the graph. It seems that this width setting is (mistakenly?) related to the window size of the graph window in stability, instead of just setting the scale factor for the entire bitmap similar to what the height setting does.

Did anyone encounter this before and found a workaround?

Many thanks on forehand!

Parents
  • It seems to be working OK for me as far as I can tell

    Please check if the problem is related to copying or pasting -- Ive done some checks looking at whats in the clipboard (eg freeclipboardviewer.com) and I have not been able to reproduce 'clipping' though you can change the size and AR of the image with the width and height settings -- the image should be consistently copied at the specified size. The image is copied as an Enhanced metafile so you should be able to rescale after it has been pasted. 

    There is a slight discrepancy between the specified size and the image size in the clipboard - I think this is due to the borders and toolbar. So its about 20units less in width and 70units less in height (on my system at least) it could also depend on monitor dpi and a host of other factors!

    the script copies this (500x500):

       with the application looking like this

    or like this (500x250)

    with the application looking like this

Reply
  • It seems to be working OK for me as far as I can tell

    Please check if the problem is related to copying or pasting -- Ive done some checks looking at whats in the clipboard (eg freeclipboardviewer.com) and I have not been able to reproduce 'clipping' though you can change the size and AR of the image with the width and height settings -- the image should be consistently copied at the specified size. The image is copied as an Enhanced metafile so you should be able to rescale after it has been pasted. 

    There is a slight discrepancy between the specified size and the image size in the clipboard - I think this is due to the borders and toolbar. So its about 20units less in width and 70units less in height (on my system at least) it could also depend on monitor dpi and a host of other factors!

    the script copies this (500x500):

       with the application looking like this

    or like this (500x250)

    with the application looking like this

Children