How to open xls file?

In Macros, how can i open a saved file (i.e. .txt or .xls) and perfrom macros for the chosen files?

  • For example, I have recorded a macro in an excel file and i need some data from a different saved file (i.e. txt or .xls). How do i use macros so that i could open that file and input the needed data from that file into the worksheet where i have recorded the macros? And also, how would macros detect an error if the file chosen by the user is not the file intended for that purpose?

  • Answer:

    You do the same thing you've already done, e.g., record the commands used to open a file and then copy the needed data into the existing worksheet. Error checking requires you to write code to verify file names and types, as well as possibly verifying validity of the data within the file.

Macross at Yahoo! Answers Visit the source

Was this solution helpful to you?

Other answers

You are asking for a big subroutine. OK openning excel files is by this line Workbooks.open "C:\My documents\file1.xls" then perform what you need Text files can be opened using the old simple VB "Open" statement.. open "C:\My documents\file2.txt" for input as #1 line input #1, se1 to open the file and read the first line into "se1" variable mail me for more info through Yahoo! Answers Read my profile, I am the XLMan

VBAXLMan

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.