Solved

Using Importpath method

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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
This article describes how you can use Custom Document Properties to store settings and other information in your workbook so that they will be available the next time you open the workbook.
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 will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

687 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