#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Help in vba

Hi everyboby..
I am new to this group, I hope u people can help me out..
I have a vba application...
when i click a button i should be able to duplicate a csv file with a
new name in the desired location of user ..
Thanks and regards
Hoping a valuable reply
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 130
Default Help in vba

Do you need the user to search for the csv file to duplicate or will he be
saving a copy of the workbook he's in? If you need to search for the file,
you'll need to prompt the user with something like this:

Sub copyCSVfile()

Dim sSourceCSVfile As String
Dim sNewCSVfile As String
Dim wbCSV As Workbook

' Get source file
Do
sSourceCSVfile = Application.GetOpenFilename(FileFilter:="CSV Files
(*.csv), _ *.csv")
Loop While (sSourceCSVfile = "False")

' Open the file
Set wbCSV = Workbooks.Open(Filename:=sSourceCSVfile, ReadOnly:=True)

' Get new name
Do
sNewCSVfile = Application.GetSaveAsFilename(InitialFileName:=Lef t
_(wbCSV.Name, Len(wbCSV.Name) - 4) & " copy", FileFilter:="CSV Files (*.csv),
_ *.csv")
Loop While (sNewCSVfile = "False")

' Save a copy and close
wbCSV.SaveAs Filename:=sNewCSVfile
wbCSV.Close SaveChanges:=False
Set wbCSV = Nothing

End Sub


HTH,
Matthew Pfluger

"DareDevil" wrote:

Hi everyboby..
I am new to this group, I hope u people can help me out..
I have a vba application...
when i click a button i should be able to duplicate a csv file with a
new name in the desired location of user ..
Thanks and regards
Hoping a valuable reply

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



All times are GMT +1. The time now is 04:54 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"