ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   macro open files (https://www.excelbanter.com/excel-programming/350236-macro-open-files.html)

MSHO

macro open files
 
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

[email protected]

macro open files
 
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)



All times are GMT +1. The time now is 03:17 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com