[AccessD] Run Excel From Within Access

Stuart McLachlan stuart at lexacorp.com.pg
Sun May 27 14:40:58 CDT 2012


And how many additional lines of code are required in addition to that line which sets the 
variable - each time you want to  open a file?

The  one line ShellExecute() (plus the  once per application Declare) isn't meant to, and does 
not "automate" Excel..  It just *opens* any type of file which has an associated application.

IMNSHO,  CreateObject() is absolutely the hardest way to display a file I have ever seen 
implemented.

-- 
Stuart

On 27 May 2012 at 13:54, William Benson wrote:

> Absolutely the hardest way to automate excel I have ever seen implemented!
> 
> Just set a variable = Createobject("Excel.Application") and control Excel
> through that.
> On May 26, 2012 10:57 PM, "Stuart McLachlan" <stuart at lexacorp.com.pg> wrote:
> 
> > I use it all the time.  It works for all office files regardless of what
> > version of office is installed
> > and whether it in on x32 or x64 Windows . Similarly,  for opening PDFs,
> > image/media files etc
> > because the user may have any one of many different applications as their
> > default viewer.
> >
> > --
> > Stuart
> >
> > On 26 May 2012 at 22:28, Arthur Fuller wrote:
> >
> > > Thanks, Stuart! ShellExecute worked like a charm.
> > > A.
> > >
> > > On Sat, May 26, 2012 at 10:13 PM, Stuart McLachlan
> > > <stuart at lexacorp.com.pg>wrote:
> > >
> > > > You need to quote the program path because it has spaces in it.
> > > >
> > > >  Application.RunQQ( "C:\Program Files (x86)\Microsoft
> > > > Office\Office11\Excel.exe") & " "  & strFile
> > > >
> > > > Alternatively, use ShellExecute() and you don't need to worry about the
> > > > path to Excel on the
> > > > machine you are running on.
> > > >
> > > >
> > > > Public Declare Function ShellExecute Lib "SHELL32.DLL" Alias
> > > > "ShellExecuteA" (ByVal
> > > > hwnd As Long, ByVal lpOperation As String, _
> > > >       ByVal lpFile As String, ByVal lpParameters As String, ByVal
> > > > lpDirectory As String, ByVal
> > > > nShowCmd As Long) As Long
> > > >
> > > > ...
> > > > ShellExecute Application.hWndAccessApp, "Open", strFile, "", "",
> > > > vbNormalFocus
> > > >
> > > >
> > > > --
> > > > Stuart
> > > >
> > > >
> > > >
> > > --
> > > AccessD mailing list
> > > AccessD at databaseadvisors.com
> > > http://databaseadvisors.com/mailman/listinfo/accessd
> > > Website: http://www.databaseadvisors.com
> > >
> >
> > --
> > Stuart McLachlan
> >
> > Ph:    +675 340 4392
> > Mob: +675 7100 2028
> > Web: http://www.lexacorp.com.pg
> >
> > --
> > AccessD mailing list
> > AccessD at databaseadvisors.com
> > http://databaseadvisors.com/mailman/listinfo/accessd
> > Website: http://www.databaseadvisors.com
> >
> -- 
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
> 

--
Stuart McLachlan

Ph:    +675 340 4392 
Mob: +675 7100 2028
Web: http://www.lexacorp.com.pg



More information about the AccessD mailing list