Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Place an excel file in Unix and access it from an excel macro

Posted on 2010-08-30
5
Medium Priority
?
592 Views
Last Modified: 2012-05-10
Hi,

I want to place an .txt in Unix and to read the file from an excel macro code.

The txt file just have the database credentials like,
User Id=xxx
Password=xxx
Initial catlog=xxx

Can someone help me ftp and read the data back
0
Comment
Question by:pnadakuditi
[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
5 Comments
 
LVL 3

Accepted Solution

by:
AndrewSwingewood earned 2000 total points
ID: 33567180
You can use the following code to run a DOS script from a macro:

Sub downloadFTP()
Dim dRetVal As Variant
dRetVal = Shell("C:\download.bat", 1)
End Sub

The contents of download.bat should be the ftp command, i.e:

ftp -i -s:c:\script.dat yourunixbox

The contents of script.dat should be the ftp commands, ie.:

username 'user for ftp site
password 'password for ftp site
cd /path_to_file
lcd c:\
get file.txt
quit

You will then be able to read the text file from the local disk.  If you want the code to be portable, you can use excel to write download.bat and script.dat prior to executing the shell command.

Hopefully this is what you need
0
 
LVL 3

Assisted Solution

by:AndrewSwingewood
AndrewSwingewood earned 2000 total points
ID: 33615529
I have just re-read your question and realised that you also need to know how to read the file into VBA.  This can be done using code similar to:

Sub Read_text_File()

Dim oFSO As New FileSystemObject
Dim oFS

Set oFS = oFSO.OpenTextFile("c:\file.TXT")

Do Until oFS.AtEndOfStream
sText = oFS.ReadLine
Loop

End Sub

0
 

Author Comment

by:pnadakuditi
ID: 33844615
Dont want to close the question.. the above solution is hoping me good.. need to implement it and verify the results
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

636 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