×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Open File location

Open File location

Open File location

(OP)
Hi all
i want to copy my table.dbf to Excel file by code .but i want to open location to save the file . how that?
i was use "copy to c:\table_name.xls type xl5" . now i want to open the any location to save the file."by code".
Greetings
Ahmed

RE: Open File location

ExcelLocation="c:\windows"
RUN /N explorer &ExcelLocation

RE: Open File location

I think the OP wants his end user to be able to select the destination for the xls file.


CODE

PRIVATE m.FILENAME
	m.FILENAME = GETFILE("XLS","File Name","Select")
	IF !EMPTY(m.FILENAME)
		COPY TO (m.FILENAME) type xl5
	ENDIF 

Regards

Griff
Keep Smileing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.

RE: Open File location

You might be right, Griff. It's such fun having to guess what this type of question means.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads

RE: Open File location

It certainly is Mike

happy shades

Regards

Griff
Keep Smileing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.

RE: Open File location

(OP)
many thanks for all
i use this code
PRIVATE m.FILENAME
m.FILENAME = GETFILE("XLS","File Name","Save")
IF !EMPTY(m.FILENAME)
COPY TO (m.FILENAME) type xl5
ENDIF
and i have got my goal
thank you very much Griff and Mike.
greetings
Ahmed

RE: Open File location

Guys, GETFILE is to pick a file, there is PUTFILE() to get a better suitable dialog for asking the user to specify directory and name for a new file.

Besides that, if you want users to see the file in Excel you can copy over your data to Excel itself with OLE automation of Excel.Application and make your Workbook visible in Excel, even before it's saved. Then users can use the save dialog of Excel, as they are used to, get the alert of Excel when closing it without saving, save in current Excel format, etc. etc.

CODE

SELECT yourtable
Copy2Excel()
&& or Copy2Excel(aliasname)

Procedure Copy2Excel()
    Lparameters tcAlias
    tcAlias = Evl(tcAlias,Alias())
    Select * From (tcAlias) into Array paExcel

    Local loExcel
    loExcel = CreateObject("Excel.Application")
    =loExcel.Workbooks.Add()
    With loExcel.ActiveWorkbook.ActiveSheet
       With .Range(.Cells(1,1),.Cells(Alen(paExcel,1),Alen(paExcel,2)))
          .Value = ExecScript("LParameters tcArrayName"+Chr(13)+"Return @&tcArrayName",'paExcel')
          .Columns.AutoFit()
       EndWith 
    EndWith 
    loExcel.Visible = .t. 

Bye, Olaf.

Olaf Doschke Software Engineering
https://www.doschke.name

RE: Open File location

The advantage of PUTFILE() over GETFILE() is that it will warn you if the file already exists. (But that might also be a disadvantage.)

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads

RE: Open File location

Well, it starts with the title caption of PUTFILE() being "Save as" automatically while you need to provide all parameters of GETFILE() to pass in the last one for the title bar caption. You can provide a new name, too, that's ok.

Bye, Olaf.

Olaf Doschke Software Engineering
https://www.doschke.name

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close