View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.misc
David T David T is offline
external usenet poster
 
Posts: 70
Default Open file with macros

Hello all-

I have a macro that opens a file on my network when I click on button. I
want this macro to open a file that is in cell(14,1) no matter what the
file's name is changed to. I've attached my current macro below. If I
change the actually file name in VBA code, then it works fine. But i want
to be able to change the file name in the Excel worksheet instead.

Private Sub CmdWireSheet_Click()

Dim objExcel As Object
Dim SchedWkbk As Workbook

On Error Resume Next
Set SchedWkbk = Nothing

Set objExcel = CreateObject("Excel.Application")

Set SchedWkbk = objExcel.Application.Workbooks.Open _
("O:\SEM\Common\Accounting\& .cells(14,1).value")
objExcel.Visible = True
On Error Resume Next

If SchedWkbk Is Nothing Then
MsgBox prompt:="Cannot find file. Please open file manually", _
Buttons:=vbOKOnly + vbQuestion

End If

End Sub