Solved

Using Importpath method

Posted on 2013-05-31
2
212 Views
Last Modified: 2013-06-20
I have a macro to extract data from an Excel tab and reformat the data and write each line to a "TXT" file.

Previously the code was written to read a CSV file, but I have changed it to read from the current worksheet tab.

I was wondering how to name the correct import path for the sheet.

Here is the original code for the CSV file.

I have attached the code for the Start and Import Macro.

Thanks

Glen
Macro.docx
0
Comment
Question by:GPSPOW
2 Comments
 
LVL 16

Expert Comment

by:Calvin Brine
ID: 39211711
Not exactly sure what you are looking for here, but I thought I'ed give it a shot.

Dim wb As Workbook, ws As Worksheet
Dim exportpath As String

exportpath = "C:\Users\Gpowers\Documents\TSI_Import.TXT"

Set wb = Workbooks.Open("C:\Users\GPowers\Documents\TSI.csv")
wb.Range("A20") = exportpath

Application.Run! "TSI_Assure.xlsm!Copy.Copy"
Application.Run! "Omission"
Application.Run! "Delete_Rows"
Application.Run! "TSI_Assure.xlsm!Import.Import"

application.Run

Open in new window

0
 
LVL 14

Accepted Solution

by:
Faustulus earned 500 total points
ID: 39215343
Yes, you can extract data from an Excel sheet and write it to a TXT file. Doing the same with a CSV file as source is more difficult because a CSV file is already in plain text format. The code which you say did the job is, in fact, calling macros in another workbook which you don't publish. Please don't! It will be a lot easier to just program what you want than to try and divine your intentions by implication.
When you write the values of all cells in a worksheet to a TXT file you are, in fact, creating a CSV file. The easiest way of doing that is to save the workbook in CSV format (File/SaveAs -> Format = CSV). You can then change the file extention to TXT and it will open in NotePad or another TXT editor.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Drop Down List with Unique/Distinct Values (enhancing the Combo-Box with a few steps and a little code) David miller (dlmille) Intro Have you ever created a data validation list from a database field or spreadsheet column (e.g., Zip Codes or Co…
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

30 Experts available now in Live!

Get 1:1 Help Now