Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I open the Excel Application

Status
Not open for further replies.

rb9999

Programmer
May 23, 2003
32
US
I frequently use Access to populate raw data in Excel spreadsheets then use Excel to report them. How do I open Excel with a particular spreadsheet running upon open? I don't always know where the Excel executable is, I would think there is a variable or something.

Any advice appreciated.
 
rb9999,

in ms vba help lookup "microsoft_excel". the DDESend function may be what you are looking for.
hth
regards,

longhair
 
if that doesn't work try this:

'''''''''
Dim excelpath As String
Dim filepath As String

'excelpath is where on your computer excel.exe resides
excelpath = "C:\Program Files\Microsoft Office\Office\Excel.exe"
filepath = "YourFilePathGoesHere"

Call Shell(excelpath & " " & filepath, 1)
'''''''''

hope this helps.
 
Code:
Function ShowExcel(ByVal strFile As String) As Boolean
On Error GoTo ErrHandler

  Dim xl As Excel.Application
  Dim wb As Excel.Workbook
  Dim sht As Excel.Worksheet
  Dim rng As Excel.Range
  
  If Dir(strFile) = "" Then
    ShowExcel = False
    GoTo ExitHere
  End If
  
  Set xl = New Excel.Application
  Set wb = xl.Workbooks.Open(strFile, Editable:=True, AddToMru:=False)
  Set sht = wb.Sheets(1)
  Set rng = sht.Range("A1")
  
  xl.Visible = True
  ShowExcel = True
    
ExitHere:
  Exit Function
ErrHandler:
  MsgBox "Error: " & Err & " - " & Err.Description
  Resume ExitHere
End Function

VBSlammer
redinvader3walking.gif

Unemployed in Houston, Texas
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top