PDA

View Full Version : How to Close Graph DataSheet with VBA?



wrecks
05-02-2009, 07:26 AM
I am processing a Word document which contains some Microsoft Graph charts. I will read and possibly change the data in a graph DataSheet.

I can find the graphs and open a DataSheet (inspect InlineShapes, OLEFormat, Edit, Object, Application, DataSheet) and get at the cells. But I'm having trouble cleaning up when done!

I just want to "Close" the DataSheet window, but there is no Close method (only Activate). The only thing I have found is OLEFormat.Object.Application.Quit -- that works, but oddly it takes 5 or 10 seconds to execute. Weird.

Using Word manually, all I have to do is type Ctrl+F4 or click the little X in the upper right corner of the Datasheet window. But damn if I can figure out how to do this from VBA.

Am I missing something obvious?
Thanks in advance...

macropod
05-03-2009, 03:57 AM
Hi wrecks,

You could use:
SendKeys "{esc}", Wait:= True

Do note, though, that Sendkeys isn't supported in Vista.

wrecks
05-03-2009, 05:45 AM
Good idea. But...


Do note, though, that Sendkeys isn't supported in Vista. A bit of a problem, that.