Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
JHB JHB is offline
external usenet poster
 
Posts: 30
Default Opening excel 2010 spreadsheet from Access

Hi:

We have an application (operarting on Windows 7, originally developed
for Access 2000 and now running under Access 2007 in compatability
mode), which was originally programed to open an Excel file
(TASCSpreadGen.xls) in Excel 2007, using the following command line:

C:\Program Files (x86)\Microsoft Office\Office12\Excel.exe /e C:\TASC
\apps\TASCSpredGen.xls

For my sins, the user has now user has converted to office 2010! I
have the Access side running fine, but the call to Excel is wrong
because Office 2010 appears to put Excel somewhere different from
where Office 2007 put it. Can someone tell me the correct call to open
Excel 2010 from within Access and execute a spreadsheet?

Thanks

John Baker
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,514
Default Opening excel 2010 spreadsheet from Access

Here's a reusable function that will work with whatever version of
Excel is the default...

In a standard module:

Public appXL As Object
Const sXLS_TO_OPEN$ = "C:\TASC\apps\TASCSpredGen.xls" '//edit to suit


Function OpenExcelFile(FileName$) As Boolean
Dim wkb As Object

On Error GoTo errexit
Set appXL = CreateObject("Excel.Application")
If Not appXL Is Nothing Then Set wkb = appXL.Workbooks.Open(FileName)

errexit:
OpenExcelFile = (Not wkb Is Nothing)
Set wkb = Nothing
End Function 'OpenExcelFile

In the procedure that currently opens the file, replace that code
with...


If OpenExcelFile(sXLS_TO_OPEN) Then
appXL.Visible = True: appXL.UserControl = True
Else
appXL.Quit: Call Notify_FileOpenFailure(sXLS_TO_OPEN)
End If
Set appXL = Nothing '//release it from memory

...so if the file opened successfully you can turn the Excel instance
over to the user by making it visible (otherwise it remains hidden),
and allowing user control. If unsuccessful you could notify the user
there was a problem opening the file...

Sub Notify_FileOpenFailure()
MsgBox "There was a problem opening " & sXLFileToOpen & "!"
End Sub

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion


  #3   Report Post  
Posted to microsoft.public.excel.misc
JHB JHB is offline
external usenet poster
 
Posts: 30
Default Opening excel 2010 spreadsheet from Access

On Feb 25, 4:59*pm, GS wrote:
Here's a reusable function that will work with whatever version of
Excel is the default...

In a standard module:

Public appXL As Object
Const sXLS_TO_OPEN$ = "C:\TASC\apps\TASCSpredGen.xls" '//edit to suit

Function OpenExcelFile(FileName$) As Boolean
* Dim wkb As Object

* On Error GoTo errexit
* Set appXL = CreateObject("Excel.Application")
* If Not appXL Is Nothing Then Set wkb = appXL.Workbooks.Open(FileName)

errexit:
* OpenExcelFile = (Not wkb Is Nothing)
* Set wkb = Nothing
End Function 'OpenExcelFile

In the procedure that currently opens the file, replace that code
with...

* If OpenExcelFile(sXLS_TO_OPEN) Then
* * appXL.Visible = True: appXL.UserControl = True
* Else
* * appXL.Quit: Call Notify_FileOpenFailure(sXLS_TO_OPEN)
* End If
* Set appXL = Nothing '//release it from memory

..so if the file opened successfully you can turn the Excel instance
over to the user by making it visible (otherwise it remains hidden),
and allowing user control. If unsuccessful you could notify the user
there was a problem opening the file...

Sub Notify_FileOpenFailure()
* MsgBox "There was a problem opening " & sXLFileToOpen & "!"
End Sub

--
Garry

Free usenet access athttp://www.eternal-september.org
Classic VB Users Regroup!
* comp.lang.basic.visual.misc
* microsoft.public.vb.general.discussion


Thanks very much.. I will try that -- appreciate it!

John
  #4   Report Post  
Posted to microsoft.public.excel.misc
JHB JHB is offline
external usenet poster
 
Posts: 30
Default Opening excel 2010 spreadsheet from Access

On Feb 26, 6:55*am, JHB wrote:
On Feb 25, 4:59*pm, GS wrote:









Here's a reusable function that will work with whatever version of
Excel is the default...


In a standard module:


Public appXL As Object
Const sXLS_TO_OPEN$ = "C:\TASC\apps\TASCSpredGen.xls" '//edit to suit


Function OpenExcelFile(FileName$) As Boolean
* Dim wkb As Object


* On Error GoTo errexit
* Set appXL = CreateObject("Excel.Application")
* If Not appXL Is Nothing Then Set wkb = appXL.Workbooks.Open(FileName)


errexit:
* OpenExcelFile = (Not wkb Is Nothing)
* Set wkb = Nothing
End Function 'OpenExcelFile


In the procedure that currently opens the file, replace that code
with...


* If OpenExcelFile(sXLS_TO_OPEN) Then
* * appXL.Visible = True: appXL.UserControl = True
* Else
* * appXL.Quit: Call Notify_FileOpenFailure(sXLS_TO_OPEN)
* End If
* Set appXL = Nothing '//release it from memory


..so if the file opened successfully you can turn the Excel instance
over to the user by making it visible (otherwise it remains hidden),
and allowing user control. If unsuccessful you could notify the user
there was a problem opening the file...


Sub Notify_FileOpenFailure()
* MsgBox "There was a problem opening " & sXLFileToOpen & "!"
End Sub


--
Garry


Free usenet access athttp://www.eternal-september.org
Classic VB Users Regroup!
* comp.lang.basic.visual.misc
* microsoft.public.vb.general.discussion


Thanks very much.. I will try that -- appreciate it!

John


There seems to be a problem here.

I am getting a "Compile error -- by ref type missmatch" when the
standard module trys to interpret sXLFileToOpen. I know I have the
right path and file name in the following setup:
Option Compare Database
Public appXL As Object
Const sXLS_TO_OPEN$ = "C:\TASC\apps\TASCSpredGen.xls" '//edit to suit
Function OpenExcelFile(FileName$) As Boolean
Dim wkb As Object
On Error GoTo errexit
Set appXL = CreateObject("Excel.Application")
If Not appXL Is Nothing Then Set wkb =
appXL.Workbooks.Open(FileName)
errexit:
OpenExcelFile = (Not wkb Is Nothing)
Set wkb = Nothing
End Function 'OpenExcelFile


, and am uncertain what the solution is.
John
  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,514
Default Opening excel 2010 spreadsheet from Access

Sorry about the syntax issue. (I moved it from a normal variable inside
the procedure to a global constant at the top of the module, but forgot
to change the syntax. The declare should read...

Const sXLFileToOpen As String ...

instead of...

Const sXLFileToOpen$

...as type symbols are not allowed in constant declares or Type
structures. My bad!

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
opening CSV file in Excel 2010 from VBA Sonnich Jensen Excel Discussion (Misc queries) 1 October 29th 11 04:34 PM
Excel 2010 (64 bit) External Data connection with Access Bill Carlson Excel Discussion (Misc queries) 0 June 2nd 11 12:10 AM
Excel 2010 not opening in maximized view racee Excel Discussion (Misc queries) 1 May 28th 10 05:39 PM
Opening an Excel Spreadsheet from Access with VBA Brad[_23_] Excel Programming 9 August 11th 06 08:31 AM
Opening linked spreadsheet file in Access Art Excel Programming 4 July 1st 05 06:15 PM


All times are GMT +1. The time now is 07:26 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"