General discussion

Locked

Excel: how to get macro to pause for fil

By rhbb ·
I wish to create a macro that includes opening a file. The macro recorder will do this but hard codes the particular file name in the code. I want the macro to pause and give me the option to select the file to be opened, and then continue after I have selected. I used to be able to do this with Lotus so am sure that Excel can too.

This conversation is currently closed to new comments.

7 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

Excel: how to get macro to pause for fil

by a.douwes In reply to Excel: how to get macro t ...

Just before you are ready to call the openfile function create a "expression.InputBox(Prompt, Title, Default, Left, Top, HelpFile, HelpContextId, Type)" (source: VBAXL8.HLP file) And ask for the file name. Store the response in a variable and pass that along to the Open function. More information can be found in the VBAXL8.HLP file on the OFFICE 97 CDROM under \office folder and probably on your hard drive under \PROGRAM FILES\MIROSOFT OFFICE\OFFICE.

Collapse -

Excel: how to get macro to pause for fil

by rhbb In reply to Excel: how to get macro t ...

The question was auto-closed by TechRepublic

Collapse -

Excel: how to get macro to pause for fil

by mike_molloy In reply to Excel: how to get macro t ...

There is a method called GETOPENFILENAME that you can use to present the file open dialog box to the users and let them pick a file to open. It doesn't actually open the file, you have to use a second statement to do that. This statement will put the name in a variable, and you use the variable in the file open statement.

You can apply a file file (*.xls, etc)if you wish, and you have a couple of other option that are described in the vba help item for the method.

Collapse -

Excel: how to get macro to pause for fil

by rhbb In reply to Excel: how to get macro t ...

The question was auto-closed by TechRepublic

Collapse -

Excel: how to get macro to pause for fil

by bdeitrick In reply to Excel: how to get macro t ...

Here's a little sub that shows you how to get a filename and open that file:

Sub PromptToOpenFile()
Application.Workbooks.Open Application.GetOpenFilename
End Sub

Bernie

Collapse -

Excel: how to get macro to pause for fil

by rhbb In reply to Excel: how to get macro t ...

The question was auto-closed by TechRepublic

Collapse -

Excel: how to get macro to pause for fil

by rhbb In reply to Excel: how to get macro t ...

This question was auto closed due to inactivity

Back to Software Forum
7 total posts (Page 1 of 1)  

Software Forums