Solved

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

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

Independent Software Vendors: 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

Suggested Solutions

Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
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 demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

733 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