View Single Post
  #1   Report Post  
Posted to microsoft.public.access.modulesdaovba,microsoft.public.excel.programming,microsoft.public.excel.worksheet.functions,microsoft.public.excel.worksheetfunctinos
Bill[_9_] Bill[_9_] is offline
external usenet poster
 
Posts: 4
Default Opening an Excel workbook with VBA from Access

I've experimented with the workbook.open method in VBA, but seem to be
getting better results with the following code. I can't see that there is a
setting with the code below that can be used to prevent the user from
receiving a notification later when the Excel file is no longer read only
and has been unlocked for editing. This can be done of course in the
workbook open method.

I would appreciate hearing whether this can be done in the code below.

Bill
____________________________________
Dim xlApp As Excel.Workbook
Dim xlWindow As Excel.Window

'Check to see if the file name passed in to
'the procedure is valid
If Dir(Path) = "" Then
MsgBox "'" & Path & "' isn't a valid path!"
Exit Sub
Else
Set xlApp = GetObject(Path)

'Show the Excel Application Window
xlApp.Parent.Visible = True

'Unhide each window in the WorkBook
For Each xlWindow In xlApp.Windows
xlWindow.Visible = True
Next

'Prevent Excel from prompting to save changes
'to the workbook when the user exits
xlApp.Saved = True

End If