Thread: Open Workbook
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default Open Workbook

Sorry misread it, it should be
Dim txtPass
Dim oWB As Workbook

On Error Resume Next
Set oWB = Workbooks("Analysis.xls")
On Error GoTo 0
If oWB Is Nothing Then
txtPass = InputBox("Please Insert Your Login")
Else
txtPass = oWB.Worksheets("Names").Cells(2, 3).Value
End If


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Bob Phillips" wrote in message
...
Pedro,

Here's one way

Dim txtPass
Dim oWB As Workbook

On Error Resume Next
Set oWB = Workbooks.Open("Analysis.xls")
On Error GoTo 0
If oWB Is Nothing Then
txtPass = InputBox("Please Insert Your Login")
Else
txtPass = oWB.Worksheets("Names").Cells(2, 3).Value
End If


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Pedro" wrote in message
...
Hi I have the following code:

If Workbooks("Analysis.xls").Worksheets("Names").Cell s(2, 3)="" Then
txtPass = InputBox("Please Insert Your Login")
Else
txtPass = Workbooks("Analysis.xls").Worksheets("Names").Cell s(2,
3).Value
End If


What code should I add in order that if the Workbooks("Analysis.xls") is

not
opened continues the macro still runs txtPass = InputBox("Please Insert

Your
Login") in the next line

Regards,
Pedro