Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 19
Default Opening a file with User Input

I am saving files based on a number and in the macro I need the user
to input the number for the file they wish to open and have the rest
of the macro continue. Right now I am using an InputBox to have the
user input the information but I dont know how to use the variable
that saves the users information and have it apart of the Open
Filename command. This does not work because that command needs to
have text and it wont let me put a variable in there. Any suggestions?

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,718
Default Opening a file with User Input

Perhaps...

Sub a()
Dim FileNum As Integer
On Error Resume Next
FileNum = InputBox("Enter file number")
If Err.Number = 0 Then
Workbooks.Open "File" & FileNum
If Err.Number = 0 Then
''file opened ok
Else
MsgBox "Could not open file"
End If
Else
MsgBox "Invalid file number"
End If
End Sub


--
Jim
wrote in message
oups.com...
|I am saving files based on a number and in the macro I need the user
| to input the number for the file they wish to open and have the rest
| of the macro continue. Right now I am using an InputBox to have the
| user input the information but I dont know how to use the variable
| that saves the users information and have it apart of the Open
| Filename command. This does not work because that command needs to
| have text and it wont let me put a variable in there. Any suggestions?
|


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 19
Default Opening a file with User Input

On Mar 27, 2:23 pm, "Jim Rech" wrote:
Perhaps...

Sub a()
Dim FileNum As Integer
On Error Resume Next
FileNum = InputBox("Enter file number")
If Err.Number = 0 Then
Workbooks.Open "File" & FileNum
If Err.Number = 0 Then
''file opened ok
Else
MsgBox "Could not open file"
End If
Else
MsgBox "Invalid file number"
End If
End Sub

--
wrote in message

oups.com...
|I am saving files based on a number and in the macro I need the user
| to input the number for the file they wish to open and have the rest
| of the macro continue. Right now I am using an InputBox to have the
| user input the information but I dont know how to use the variable
| that saves the users information and have it apart of the Open
| Filename command. This does not work because that command needs to
| have text and it wont let me put a variable in there. Any suggestions?
|


This works great, do you know if there is a way to set a directory so
the program knows where to look for the file the user will specify.
Thank you.

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 95
Default Opening a file with User Input

take one step in between. Define a string that contains the filename. Based
on the feedback from the inputbox add the number to the string - the result
is again a string. Thus MyFilename = MyFilename & inputbox
thereafter use the open command

" wrote:

I am saving files based on a number and in the macro I need the user
to input the number for the file they wish to open and have the rest
of the macro continue. Right now I am using an InputBox to have the
user input the information but I dont know how to use the variable
that saves the users information and have it apart of the Open
Filename command. This does not work because that command needs to
have text and it wont let me put a variable in there. Any suggestions?


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Have user input converted to uppercase in same cell as input? Shannonn New Users to Excel 1 June 20th 06 03:19 AM
Excel 2003 crashes when opening a file from one particular user [email protected] Excel Discussion (Misc queries) 0 May 17th 06 05:23 PM
restrict a user from opening a dbf file from excel? WyldX Excel Discussion (Misc queries) 0 January 18th 06 01:40 PM
How do I deny opening and viewing any file to any user and lock i. Leah Wright Excel Discussion (Misc queries) 1 April 22nd 05 11:59 PM
restrict opening Excel file residing on a shared drive to one user k-ham Excel Discussion (Misc queries) 1 January 7th 05 01:57 AM


All times are GMT +1. The time now is 08:47 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"