Solved

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

Posted on 2010-08-30
5
573 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
  • 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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 code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
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…

856 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