View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Create a reference to a workbook which is already open

Why not just open it readonly?

Dim Wkbk as workbook
dim myFilename as string
myfilename = ThisWorkbook.Worksheets("Timesheet").Range("T2").T ext _
& "Data File NEW.xls"

set wkbk = workbooks.open(filename:=myfilename,readonly:=true )



wrote:

I am looking to create a reference to a workbook which is already
open. I have used the code below but this throws the error '32813':
name conflicts with existing module, project or object library'. The
project that I am trying to reference has a unique name.

Sub Create_Reference()
Dim Path1 As String
Path1 = ThisWorkbook.Worksheets("Timesheet").Range("T2").T ext &
"Data File NEW.xls"
Application.VBE.ActiveVBProject.References.AddFrom File Path1
End Sub

What I am really trying to do is have the workbook that I am
referencing opened as a Read Only copy.

Any help on this would be appreciated


--

Dave Peterson