What is .OpenTest

  • Thread starter Thread starter Minitman
  • Start date Start date
M

Minitman

Greetings,

I was setting a variable called "wb" to be the temporary name of the
current Workbook I needed to open (once opened, I returned the value
of wb to vbNullString). I had dimmed this "wb" as Workbooks. I was
trying to see if it was working (It was not but that has been fixed)
by using a MsgBox asking for wb.Name. ",Name" was not available! But
as I was scrolling though what was available, I came across
".OpenTest". When I tried to find information in MS Help there was
nothing. I then went to the original setting for "wb"

Set wb = WorkBooks(MCL.xls)

and tried to attach ".OpenTest" there and it was not available.

Anyone know what ".OpenTest" does and how to use it?

Any information would be appreciated.

-Minitman
 
I bet it's a typo and should be .openteXt (text, not test).

I'd use it like:

Option Explicit
Sub Testme01()

Dim myFileName As Variant
Dim wb as workbook 'not workbooks -- with an S

myFileName = Application.GetOpenFilename(filefilter:="Text Files, *.Txt", _
Title:="Pick a File")

If myFileName = False Then
MsgBox "Ok, try later" 'user hit cancel
Exit Sub
End If

Workbooks.OpenText Filename:=myFileName

set wb = activeworkbook

'...code that does something.

End Sub
 
Hey Dave,

Thanks for the reply.

I didn't consider a typo in MS help - I mean Micro$oft NEVER makes
mistakes, right? <VBG>

I was looking for a simple way to see if a workbook was open, I
thought maybe this was it - silly me.

-Minitman
 
Hey Dave,

This is embarrassing, it was indeed ".OpenText". I was mistaken,
sorry for the post.

-Minitman
 
Dim TestWkbk as workbook

set testwkbk = nothing
on error resume next
set testwkbk = workbooks("somenamehere.xls") 'no drive, no path!
on error goto 0

if testwkbk is nothing then
'not open
'open it???
set testwkbk = workbooks.open(Filename:="c:\yourpath\somenamehere.xls")
end if

msgbox testwkbk.worksheets(1).range("a1").text
 
Thanks Dave,

That works for me.

-Minitman

Dim TestWkbk as workbook

set testwkbk = nothing
on error resume next
set testwkbk = workbooks("somenamehere.xls") 'no drive, no path!
on error goto 0

if testwkbk is nothing then
'not open
'open it???
set testwkbk = workbooks.open(Filename:="c:\yourpath\somenamehere.xls")
end if

msgbox testwkbk.worksheets(1).range("a1").text
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top