ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Workbooks.Open using Dialog box (https://www.excelbanter.com/excel-programming/412993-workbooks-open-using-dialog-box.html)

Sam

Workbooks.Open using Dialog box
 
Is there a way to open a file as ReadOnly using
Application.Dialog(xlDialogOpen).Show?

I want to write re-usable code to allow another end-user to open an Excel
workbook as ReadOnly without first requiring someone else on the network
first having it open.

I would use Workbooks.Open myPath & myFile & "xls" but I don't know what
file the end user will want to open.

Any help will be appreciated.

Thanks,

Sam

Ron de Bruin

Workbooks.Open using Dialog box
 
Try GetOpenFilename

Sub test()
Dim FName As Variant
Dim wb As Workbook
Dim MyPath As String
Dim SaveDriveDir As String

SaveDriveDir = CurDir

MyPath = ThisWorkbook.Path
ChDrive MyPath
ChDir MyPath

FName = Application.GetOpenFilename(filefilter:="Excel Files (*.xls), *.xls")
If FName < False Then
Set wb = Workbooks.Open(FName, ReadOnly:=True)
End If

ChDrive SaveDriveDir
ChDir SaveDriveDir

End Sub


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Sam" wrote in message ...
Is there a way to open a file as ReadOnly using
Application.Dialog(xlDialogOpen).Show?

I want to write re-usable code to allow another end-user to open an Excel
workbook as ReadOnly without first requiring someone else on the network
first having it open.

I would use Workbooks.Open myPath & myFile & "xls" but I don't know what
file the end user will want to open.

Any help will be appreciated.

Thanks,

Sam



All times are GMT +1. The time now is 12:29 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com