Hi amroo
Two things here. Is the file that they type in open already ? If not the .Activate will not work. If it is not open and you do want to open it, use the GetOpenFileName dialog, rather than a Inputbox. They cannot mistype any names then.
Sub tryThis()
Dim namefile As String
namefile = Application.GetOpenFilename
If namefile = False Then Exit Sub
Workbooks.Open namefile
End Sub
.....If the file is open then use this syntax:
Sub OrThis()
Dim namefile As String
namefile = InputBox("enter the name file to import")
If namefile = "" Then Exit Sub
Windows(namefile & ".txt").Activate
End Sub
But personally I would not have enough faith in users to type the name of a file you want them to Activate. I would fill a Listbox or Combobox myself.
Dave
OzGrid Business Applications
.....If the file is open then use this syntax: namefile = InputBox("enter the name file to import") If namefile = "" Then Exit Sub Windows(namefile & ".txt").Activate But personally I would not have enough faith in users to type the name of a file you want them to Activate. I would fill a Listbox or Combobox myself. Dave
Dave, agree with you....don't let users type in
anything.....give them options.
Just one other point;
the False should be "False" string and not Boolean
in the routine trythis.
Ivan
The code will work with False (Boolean) OR "False" (String)
Jerid
Jerid
Have you tried it by selecting a file name ?
On cancel it works.
Ivan
Ivan
Sorry, I forgot one key piece of info. You need to change the filename variable to a variant.
Jerid