Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.access.modulesdaovba,microsoft.public.excel.programming,microsoft.public.excel.worksheet.functions,microsoft.public.excel.worksheetfunctinos
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



  #2   Report Post  
Posted to microsoft.public.access.modulesdaovba,microsoft.public.excel.programming,microsoft.public.excel.worksheet.functions,microsoft.public.excel.worksheetfunctinos
external usenet poster
 
Posts: 1,549
Default Opening an Excel workbook with VBA from Access

Not that I know of, however, this should work...
'--
Sub StartFresh()
Dim xlApp As Excel.Application
Dim WB As Excel.Workbook
Dim WS As Excel.Worksheet
Dim strPath As String

strPath = "C:\Documents and Settings\MyGirlFriends.xls"
Set xlApp = New Excel.Application
Set WB = xlApp.Workbooks.Open(strPath, , , , , , , , , , False)
Set WS = WB.Sheets(1)
xlApp.Visible = True

'do stuff

Set WS = Nothing
WB.Close True ' or False
Set WB = Nothing
xlApp.Quit
Set xlApp = Nothing
End Sub
--
Jim Cone
Portland, Oregon USA


"Bill"
wrote in message
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



  #3   Report Post  
Posted to microsoft.public.access.modulesdaovba,microsoft.public.excel.programming,microsoft.public.excel.worksheet.functions,microsoft.public.excel.worksheetfunctinos
external usenet poster
 
Posts: 4
Default Opening an Excel workbook with VBA from Access

Thanks Jim, I'll try this.

Bill

"Jim Cone" wrote in message
...
Not that I know of, however, this should work...
'--
Sub StartFresh()
Dim xlApp As Excel.Application
Dim WB As Excel.Workbook
Dim WS As Excel.Worksheet
Dim strPath As String

strPath = "C:\Documents and Settings\MyGirlFriends.xls"
Set xlApp = New Excel.Application
Set WB = xlApp.Workbooks.Open(strPath, , , , , , , , , , False)
Set WS = WB.Sheets(1)
xlApp.Visible = True

'do stuff

Set WS = Nothing
WB.Close True ' or False
Set WB = Nothing
xlApp.Quit
Set xlApp = Nothing
End Sub
--
Jim Cone
Portland, Oregon USA


"Bill"
wrote in message
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





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 an Excel workbook with VBA from Access Bill[_9_] Excel Worksheet Functions 2 June 7th 09 04:34 PM
Slow Opening Excel Workbook from Access Skip Bisconer Excel Programming 8 December 5th 07 03:00 AM
Unprotect a workbook while opening from Access scottydel Excel Programming 0 August 23rd 07 10:28 PM
user cannot access his share workbook after opening network path. phil Excel Discussion (Misc queries) 0 September 26th 06 04:48 PM
excel VBA problem - setting workbook as variable & opening/re-opening safe Excel Programming 1 August 20th 04 12:22 AM


All times are GMT +1. The time now is 08:37 PM.

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"