Solved

Using Importpath method

Posted on 2013-05-31
2
220 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Improved? Move/Copy Add-in Replacement - How to avoid the annoying, “A formula or sheet you want to move or copy contains the name XXX, which already exists on the destination worksheet.” David Miller (dlmille)  It was one of those days… I wa…
This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

777 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