LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default Opening an Excel File

The following code tests whether a file is open on my computer and if
it isn't, it opens the file, and if it is already open, it tells me
that.

sub OpenMyFile()
dim myPath as string
dim myFile as string
dim wkbk as Workbook

myPath = "R:\share\ . . . Folder\"
myFile = "SomeFileName.xlsm"

set wlbk = Nothing
On Error Resume Next
set wkbk = Workbooks(myFile)
On Error GoTo 0

If wkbk Is Nothing Then
Set wkbk = Workbooks.Open(Filename:=myPath & myFile)
Else
MsgBox ("It's already open")
End If
End Sub

The problem is that the file is on a network drive and others can open
it. If someone else has it open, this routine will go ahead and open
in on my computer as (Read Only). I would prefer that it not do that
but instead give me the prompt that I would get if were to use to
navigate to it and try to open it. In that case there would be a
prompt telling who had it open and giving choices to open as Read Only
or Notifiy or Cancel. Can code to that effect be added to this
procedure?
 
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
Macro for Opening Reuters, Opening Excel File, Closing Excel File Tsp245 Excel Programming 2 August 14th 08 07:24 PM
opening a file in Excel starts application but dose not open file Bob Shelton Excel Discussion (Misc queries) 1 July 2nd 08 07:51 PM
Opening file in Excel 2003 opens multipule instances of same file Ed_B Excel Discussion (Misc queries) 1 June 21st 07 07:10 PM
opening an excel file opens a duplicate file of the same file skm Excel Discussion (Misc queries) 1 December 7th 05 05:52 PM
Error:Invalid File format,while opening an Excel Template file Saurabh Excel Programming 1 January 17th 05 07:15 AM


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"