activate unknown workbook

T

Tom

Hi,

I'm using a macro that opens a dialigbox to open a file.
I know the filename begins with ABC.
ex : ABC XXXXX of ABC YYYY.

Is it possible to switch between a filename that is
always the same and ABC XXXXX
The file I know (DEF) I select with :
Windows("DEF.xls").Activate

Can I use something like Windows("ABC*.xls").Activate ?

Thanks
Tom
 
T

Tom Ogilvy

for each wkbk in Application.Workbooks
if Ucase(left(wkbk.Name,3)) = "ABC" then
wkbk.Activate
exit sub
end if
Next
 
D

Dave Peterson

And you have other replies to your other post.
Hi,

I'm using a macro that opens a dialigbox to open a file.
I know the filename begins with ABC.
ex : ABC XXXXX of ABC YYYY.

Is it possible to switch between a filename that is
always the same and ABC XXXXX
The file I know (DEF) I select with :
Windows("DEF.xls").Activate

Can I use something like Windows("ABC*.xls").Activate ?

Thanks
Tom
 
T

Tom

I'm using :
Sub test()
Dim wbk As Workbook
For Each wbk In Application.Workbooks
If UCase(Left(wbk.Name, 3)) = "Exp" Then
wbk.Activate
ActiveSheet.Unprotect
With ActiveWindow
.DisplayGridlines = True
.DisplayHeadings = True
End With
Columns("A:K").Select
Selection.EntireColumn.Hidden = False

Exit For
End If
Next
Windows("DEF.xls").Activate
End Sub

But it does nothing, even no error.

What's wrong

Thank you very much in advance !
Tom
 
D

Dave Peterson

If UCase(Left(wbk.Name, 3)) = "Exp" Then

If UCase(Left(wbk.Name, 3)) = "EXP" Then

(ucase means upper case)
 
G

Guest

problem is solved
Exp has to be EXP
Thx !
-----Original Message-----
I'm using :
Sub test()
Dim wbk As Workbook
For Each wbk In Application.Workbooks
If UCase(Left(wbk.Name, 3)) = "Exp" Then
wbk.Activate
ActiveSheet.Unprotect
With ActiveWindow
.DisplayGridlines = True
.DisplayHeadings = True
End With
Columns("A:K").Select
Selection.EntireColumn.Hidden = False

Exit For
End If
Next
Windows("DEF.xls").Activate
End Sub

But it does nothing, even no error.

What's wrong

Thank you very much in advance !
Tom
.
 

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

Top