1
I updated my Office version for 2016 and some macros stopped working properly. The routine when executed in isolation works properly, but when it enters a process it stops working. The macro in question makes the following statements. Copies a Range:
Set rng = .Range("S1:W4")
rng.CopyPicture xlScreen, xlBitmap
Creates a chart:
Set cht = .ChartObjects.Add(0, 0, rng.Width, rng.Height)
Pastes the image on the chart Export the image in JPGEG format to a folder.
As informed, the routine works if used separately. But when I run the form, the routine stops working. The chart is exported but no image. The file size is also reduced.
All indications are that the problem is not a version update necessarily, but adverse conditions execution. Your call
.Range("S1:W4")
, for example, implicitly executes the functionRange
to the active spreadsheet tab (ActiveWorksheet
). Maybe the moment you execute this call "within the form" or "within a process" (whatever that means, since you didn’t contextualize it properly), there is no active tab or it is not the expected one. I suggest changing the code to invoke the function in the correct tab.– Luiz Vieira