Solved

Using Importpath method

Posted on 2013-05-31
2
198 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
Comment Utility
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
Comment Utility
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Introduction While answering a recent question (http:/Q_27311462.html), I created an alternative function to the Excel Concatenate() function that you might find useful.  I tested several solutions and share the results in this article as well as t…
How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

762 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

11 Experts available now in Live!

Get 1:1 Help Now