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
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:
- How do I open a pdf file in my e'mail attachment?Best solution by Yahoo! Answers
- How can I open a vcf file?Best solution by file.org
- How can I open a jpeg file?Best solution by answers.microsoft.com
- How can I open a .mmo file?Best solution by Yahoo! Answers
- How do I open a .xls file attachment?Best solution by tech-faq.com
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
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.