macro open files

G

Guest

Im trying to write a macro to prompt a user to select a file and then open it.

This is the link to the file that I keep trying:
C:\Documents and Settings\All Users\Documents\Coop Students\Small Package
Rates\UPS rates\2006\Air\

The file is then in that Air folder.

The year (2006) is the second input box and the file name is the first.

This is what i have so far:
I keep getting error- GetOpenfilname application failed

Sub Macro112_4()


Dim filetypenm As String
filetypenm = InputBox("Enter File Name you would like to compare")

Dim nm As Integer
nm = InputBox("Enter Year you would like to compare")
Application.GetOpenFilename (["C:\Documents and
Settings\AllUsers\Documents\Coop Students\Small Package Rates\UPS rates\" &
nm & "\Air\" & filetypenm])


End Sub


HELP PLEASE!

Thanks in advance,

Mikayla
 
S

soxcpa

I don't have the macro so I can't test this but a lot of the file
access functions do not like expressions in the function. You can avoid
this by creating a temporary string to hold the value you are
evaluating. Try adding:

Dim myFileName as String
myFileName = "C:\Documents and Settings\AllUsers\Documents\Coop
Students\Small Package Rates\UPS rates\" & nm & "\Air\" & filetypenm

and changing the action to:

Application.GetOpenFilename(myFileName)
 

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