Phil Smith said:
Actually, it looks pretty concise. It appears that if Escel was open
before this subroutine is run, it does not attempt to close it. So this
is a fairly safe routine to run if Excel IS open?
Yes it is. That is the purpose of the code you are asking about. Notice it
first tries a GetObject. The GetObject requires the process already be in
memory. If it fails, it uses the CreateObject to start up an instance of
Excel
Now, here is a question, for curiosity at this point, I would just be
interested in a little guidance, simple because I expect it to be much
more intense... in terms of time and code, but I may experiment with it
as a learning process...
I think I understand from your example how to open Excel and a specific
spreadsheet, and how to set the properties of that spreadsheet, like
Autofilter. I will look for an online reference for some of the other
items that can be similarly set. The question is:
Is it possible to Build a Pivot table in a similar fashion?
Anything you can do directly in Excel, You can do through Automation.
Manipulating and Excel object is code intensive, however. If you want to
learn more about how the Excel Object model is constructed, use the Object
Browser in the VBA editor.
Another trick that will help is to open a spreadsheet in Excel, start
recording a macro, do what you want to do, then stop the recording. Then go
into the macro editor, and you can copy the code it created and use that. It
will take some modification to run it from Access so the object references
are correct, but it is a great learning tool and a decent short cut.