PDA

View Full Version : Charts and forms freeze after VBA macro execution



Vatlin
06-12-2019, 12:49 AM
Hello,


I have an issue with an Excel VBA tool (find a simplified version enclosed) I created.
When I run my code Plot_Chart (update charts form) all charts and forms freeze or disappear.
I understand it as a display bug because after the save and restart everything works again!

I am using Microsoft Office Standard 2016
It seems to be happening only from a few month, this code has been working without issue for a while before

I tried:
-Disable hardware acceleration
-Disconnect other displays
-Other computers with windows 7/10

Nothing worked... Any idea?

Aussiebear
06-12-2019, 02:28 AM
Have you for instance used Option Explicit at the start of your code, or stepped through your code to test each line?

p45cal
06-12-2019, 03:30 AM
After running Plot_Chart several times the chart disappeared. It was there though.
No idea what's going on, however:
1. Disabling all Application.Screenupdating = False lines caused the problem to go away.
2. I added a New Window via the Window section of the View tab of the ribbon which created a new window with the chart visible!

Vatlin
06-12-2019, 03:38 AM
I just solved the issue by removing Worksheet_Ref.ChartObjects(1).Select before deleting the selected chart.
It seems that Excel doesn't like it ! Always follow the most important rule:
Don't use .Select methods
Thank you for your help, you can close the topic

p45cal
06-12-2019, 03:45 AM
I just solved the issue by removing Worksheet_Ref.ChartObjects(1).Select before deleting the selected chart. Excellent! I would never have thought that would solve it. What pointed you in that direction?

Vatlin
06-12-2019, 04:02 AM
It was a difference with an older version of the tool without this bug.
I am still trying to find a solution to the Worksheet_Ref.ChartObjects(1).Copy command which randomly bug if I copied something before running the code