View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bernie Deitrick Bernie Deitrick is offline
external usenet poster
 
Posts: 5,441
Default Open specific workbook

Li,

I would use code in the workbook open event that asks for the path to that file the first time that
the add-in is opened, along the lines of

Public MyFName As String

Private Sub Workbook_Open()

If Sheets(1).Range("A1").Value = "" Then
MsgBox "Please browse to and select your Prod_01.xlsx file in the next dialog box"
Sheets(1).Range("A1").Value = Application.GetOpenFilename
End If
MyFName = Sheets(1).Range("A1").Value
End Sub

Then anytime your add-in needs that file, use

Workbooks.Open MyFName


HTH,
Bernie
MS Excel MVP


"Li Jianyong" wrote in message
...
Dear Sirs,

I want to program an addin to my excel to open a workbook named
"Prod_01.xlsx". and I will share this addin with my colleagues,they have same
file in their computer,but kept in different path. so I thin my macro should
always find the workbooks("Prod_01.xlsx") firstly, then open it.Anybody can
provide these code?

thanks advancely.