?
Solved

Using Importpath method

Posted on 2013-05-31
2
Medium Priority
?
245 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 2000 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
After seeing numerous questions for Dynamic Data Validation I notice that most have used Visual Basic to solve the problem. This suggestion is purely formula based and can be used in multiple rows.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

771 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