Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default Transfer flat file to a Shared folder.


The script below saves my spreadsheet to a delimited flat file. After
the file is saved is it possible to have the scripted automatically
transfer the file to a shared folder on another computer.


Sub FlatExport()
Dim FileName As Variant
Dim Sep As String
FileName =
Application.GetSaveAsFilename(InitialFileName:=vbN ullString,
FileFilter:="Text Files (*.txt),*.txt")
If FileName = False Then
''''''''''''''''''''''''''
' user cancelled, get out
''''''''''''''''''''''''''
Exit Sub
End If
Sep = Application.InputBox("Enter a separator character.",
Type:=2)
If Sep = vbNullString Then
''''''''''''''''''''''''''
' user cancelled, get out
''''''''''''''''''''''''''
Exit Sub
End If
Debug.Print "FileName: " & FileName, "Separator: " & Sep
ExportToTextFile FName:=CStr(FileName), Sep:=CStr(Sep), _
SelectionOnly:=False, AppendData:=True
End Sub

Thanks

Happy New Year


Little Penny
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Transfer flat file to a Shared folder.

Do you connect to that shared folder on that other pc?

If yes, then you could look at FileCopy and Erase in VBA's help to see how to
copy a file and delete a file.

Or you could look at the Name statement that will move it across drives/folders
in one step.

But heck, if you're connected to that shared folder, why not just choose a file
on that drive when you see the .getsaveasfilename dialog?

===
If you're not connected to that folder, maybe you can save it to a common
network share that both you and the other user have access to.



Little Penny wrote:

The script below saves my spreadsheet to a delimited flat file. After
the file is saved is it possible to have the scripted automatically
transfer the file to a shared folder on another computer.

Sub FlatExport()
Dim FileName As Variant
Dim Sep As String
FileName =
Application.GetSaveAsFilename(InitialFileName:=vbN ullString,
FileFilter:="Text Files (*.txt),*.txt")
If FileName = False Then
''''''''''''''''''''''''''
' user cancelled, get out
''''''''''''''''''''''''''
Exit Sub
End If
Sep = Application.InputBox("Enter a separator character.",
Type:=2)
If Sep = vbNullString Then
''''''''''''''''''''''''''
' user cancelled, get out
''''''''''''''''''''''''''
Exit Sub
End If
Debug.Print "FileName: " & FileName, "Separator: " & Sep
ExportToTextFile FName:=CStr(FileName), Sep:=CStr(Sep), _
SelectionOnly:=False, AppendData:=True
End Sub

Thanks

Happy New Year

Little Penny


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default Transfer flat file to a Shared folder.

On Tue, 01 Jan 2008 19:48:56 -0600, Dave Peterson
wrote:

Application.GetSaveAsFilename



How do I get the saveas dialog box to open to a folder I choosed?

Application.GetSaveAsFilename
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Transfer flat file to a Shared folder.

First, do you mean open the file?

Dim myFilename as Variant
dim wkbk as workbook
myfilename = application.getsaveasfilename(....)
if myfilename = false then
'user hit cancel
exit sub '???
end if
set wkbk = workbooks.open(filename:=myfilename)

If you really were asking how to choose a folder -- not open a file:

Jim Rech has a BrowseForFolder routine at:
http://www.oaltd.co.uk/MVP/Default.htm
(look for BrowseForFolder)

John Walkenbach has one at:
http://j-walk.com/ss/excel/tips/tip29.htm

If you and all your users are running xl2002+, take a look at VBA's help for:
application.filedialog(msoFileDialogFolderPicker)




Little Penny wrote:

On Tue, 01 Jan 2008 19:48:56 -0600, Dave Peterson
wrote:

Application.GetSaveAsFilename


How do I get the saveas dialog box to open to a folder I choosed?

Application.GetSaveAsFilename


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
file in shared folder keeps reverting back to Read-only sara b Excel Discussion (Misc queries) 0 November 3rd 08 08:45 PM
To make the excel file in shared folder to be editable by every us Shefu Excel Worksheet Functions 1 September 12th 08 12:59 PM
how do I convert an excel file to a flat text file Lannutslp Excel Discussion (Misc queries) 1 June 3rd 05 10:17 AM
Convert excel file to flat text file Lannutslp Excel Discussion (Misc queries) 1 June 1st 05 03:48 AM
Convert excel file to flat text file Gary's Student Excel Discussion (Misc queries) 0 June 1st 05 12:17 AM


All times are GMT +1. The time now is 03:39 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"