Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,080
Default creating a dos command in VBE

Look at the SaveCopyAs method.

--

Vasant

"norika" wrote in message
...
Hi all experts,

I am new to excel VBA, and need some help in this topic.

I got a excel data file , and its data would be changed day by day. In

order
to trace mistakes and backup reason, I'm going to create some vba coding

to
make a backup file in the same directory if I pressed a custom button in

my
tool bar.

I create a stupid macro to save the active orginial file to another file
name, but after the code finish running, the existing file already

replaced
by new file, because I used "SAVE AS" function in my coding.

What should I do if I just want an to copy my existing file to the same
directory?

Is it possible to run a dos command like " copy xxx.xls yyy.xls" in VBA?


Best Regards,


Newbie.

****************

Sub Macro1()
'
' marco save file
'

Dim wks As Worksheet
Dim spath As String
Dim sfilename As String
Dim sfilename1 As String
Dim sfilename2 As String
Dim fullname As String
Dim dayname As String
Dim monthname As String



Application.ScreenUpdating = False
Application.DisplayAlerts = False


spath = "c:\documents and settings\kay\my documents\logistics\semiwell\"

dayname = CStr(Day(Now()))
monthname = getmonth(Month(Now()))
sfilename1 = "Semi_Bup_" & dayname & monthname
sfilename2 = ".xls"
fullname = sfilename1 & sfilename2

ActiveWorkbook.SaveAs Filename:=(spath & fullname), _
FileFormat:=xlNormal, Password:="", _
writerespassword:="", _
ReadOnlyRecommended:=False, _
CreateBackup:=False

addtomru = True


End Sub









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
command code ( GOTO command) in formula calan New Users to Excel 1 June 11th 09 09:44 AM
Pivot Table Error Message - "Command Text not set for command obje Jeff Divian Excel Discussion (Misc queries) 0 November 7th 07 10:26 PM
Creating a Command Button on a worksheet GeorgeJ Excel Discussion (Misc queries) 0 August 1st 07 09:42 PM
Creating Command button Conditionally Todd Huttenstine[_2_] Excel Programming 2 January 17th 04 07:57 PM
Exel2000 VBA - Creating a Command Bar - Error: "Object Variable or With not Set" keepitcool Excel Programming 0 August 11th 03 12:29 PM


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