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

  • Dear Pat,

    Thanks for the swift reply. I was a bit puzzled by this, as it is very reproducible on my end. But then I played around a bit with the graph formatting settings in Stability, and it turns out that this happens in some combinations of settings, but not in others. I've found a setting that works, so for me the issue is resolved, but for information, this is what I find:

    Settings that cause the cropping in my set-up:

    Graph picture in clipboard (note it's not showing the full graph up to 180 degrees):

    Graph settings in Stability that do not cause the cropping issue:

    Correct graph picture in clipboard:

    Above settings are per example, I've found more combinations of graph settings in stability that work and that don't. No clue what's causing this or if it's something to do with my specific installation and hardware, but interesting anyway.

    Hope this helps you or anyone else experiencing the same.

    Thanks!

Reply
  • Dear Pat,

    Thanks for the swift reply. I was a bit puzzled by this, as it is very reproducible on my end. But then I played around a bit with the graph formatting settings in Stability, and it turns out that this happens in some combinations of settings, but not in others. I've found a setting that works, so for me the issue is resolved, but for information, this is what I find:

    Settings that cause the cropping in my set-up:

    Graph picture in clipboard (note it's not showing the full graph up to 180 degrees):

    Graph settings in Stability that do not cause the cropping issue:

    Correct graph picture in clipboard:

    Above settings are per example, I've found more combinations of graph settings in stability that work and that don't. No clue what's causing this or if it's something to do with my specific installation and hardware, but interesting anyway.

    Hope this helps you or anyone else experiencing the same.

    Thanks!

Children