On Sep 19, 3:51 pm, "CompleteN...@comcast.net"
<completen...@comcast.net> wrote:
> I'm trying to find out how to make a string variable's value the name of the
> LAST sheet in an EXTERNAL workbook. In lieu of actually setting a string
[quoted text clipped - 31 lines]
>
> CompleteNewb
While it is possible to access a closed workbook, I find it easier to
just open the workbook in question and keep it hidden. Something like
this:
Sub foofer()
Dim wb As Workbook
On Error GoTo errHandler
Application.ScreenUpdating = False
Set wb = Workbooks.Open("C:\VBATest.xls", , True)
MsgBox wb.Sheets(wb.Sheets.Count).Name
wb.Close False
errHandler:
Set wb = Nothing
Application.ScreenUpdating = True
End Sub
You might want to consider throwing in some code to check if the
workbook in question is already open.
CompleteNewb - 22 Sep 2007 21:29 GMT
Many thnaks, JW, worked like a charm. I'm cool with opening and keeping
hidden, it's a perfectly fine substitute, and from what I've seen about
accessing closed workbooks, it's worth saving the trouble.
Thanks a lot, you saved me hours of fruitless experimentation.
The Complete Newb
> On Sep 19, 3:51 pm, "CompleteN...@comcast.net"
> <completen...@comcast.net> wrote:
[quoted text clipped - 56 lines]
> You might want to consider throwing in some code to check if the
> workbook in question is already open.