Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.access.modulesdaovba,microsoft.public.excel.programming,microsoft.public.excel.worksheet.functions,microsoft.public.excel.worksheetfunctinos
|
|||
|
|||
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
Posted to microsoft.public.access.modulesdaovba,microsoft.public.excel.programming,microsoft.public.excel.worksheet.functions,microsoft.public.excel.worksheetfunctinos
|
|||
|
|||
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
Posted to microsoft.public.access.modulesdaovba,microsoft.public.excel.programming,microsoft.public.excel.worksheet.functions,microsoft.public.excel.worksheetfunctinos
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Opening an Excel workbook with VBA from Access | Excel Worksheet Functions | |||
Slow Opening Excel Workbook from Access | Excel Programming | |||
Unprotect a workbook while opening from Access | Excel Programming | |||
user cannot access his share workbook after opening network path. | Excel Discussion (Misc queries) | |||
excel VBA problem - setting workbook as variable & opening/re-opening | Excel Programming |