wageslave101
Board Regular
- Joined
- Jul 18, 2007
- Messages
- 154
This sub checks if the workbook is open, which is in the format "Rep Name.xls", this one works fine.
However rather than going in and entering in the Rep Name I'd like to grab the details from a data entered into the Sheet
But when I redo the IsRepOpen() sub it does nothing. Stepping through it processes the line Workbooks.Open (wkbk) but does nothing.
I thought that the string might not be reading or something so I checked with a messagebox
Which shows the string as Rep Name fine
Can anyone help with why this is behaving or what I need to do to make it play nice?
Thanks,
WageSlave101
Code:
Sub IsRepOpen()
Dim wbook As Workbook, wkbk As Variant
wkbk = "Rep Name"
On Error Resume Next
Set wbook = Workbooks(wkbk)
If wbook Is Nothing Then
Workbooks.Open (wkbk)
Set wbook = Nothing
Else
Set wbook = Nothing
End If
End Sub
However rather than going in and entering in the Rep Name I'd like to grab the details from a data entered into the Sheet
But when I redo the IsRepOpen() sub it does nothing. Stepping through it processes the line Workbooks.Open (wkbk) but does nothing.
Code:
Sub IsRepOpen()
Dim wbook As Workbook, wkbk As Variant
TheRep = Worksheets("Sheet1").Range("A2").Value & " " & Worksheets("Sheet1").Range("B2").Value
wkbk = TheRep
On Error Resume Next
Set wbook = Workbooks(wkbk)
If wbook Is Nothing Then
Workbooks.Open (wkbk)
Set wbook = Nothing
Else
Set wbook = Nothing
End If
End Sub
I thought that the string might not be reading or something so I checked with a messagebox
Code:
Sub RepName()
MsgBox Worksheets("Sheet1").Range("A2").Value & " " & Worksheets("Sheet1").Range("B2").Value & ".xls"
End Sub
Which shows the string as Rep Name fine
Can anyone help with why this is behaving or what I need to do to make it play nice?
Thanks,
WageSlave101