Solved

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

Posted on 2010-08-30
5
586 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 500 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 500 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

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

FreeBSD on EC2 FreeBSD (https://www.freebsd.org) is a robust Unix-like operating system that has been around for many years. FreeBSD is available on Amazon EC2 through Amazon Machine Images (AMIs) provided by FreeBSD developer and security office…
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…
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

705 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