LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Directory/File movement with VBA

DartRef = "CPCT " & xlmonth2 & " CDART.xls"
DartPth = "\\V1sacpdofc1\CPCTProjects\PMO\DART\F0" & XlYear & "_DART\" &
xlmonth2 & " DART 0" & XlYear & "\" & DartRef

If Dir(DartPth) < "" Then
xlApp.Workbooks.Open (DartPth), 0, ReadOnly = True
xlApp.ActiveWorkbook.Windows(1).Visible = False
Else
XLMonth = Month(Date) - 1
If XLMonth = 0 Then
XLMonth = "12"
xlmonth2 = "Dec"
XlYear = 5
DartRef = "CPCT " & xlmonth2 & " CDART.xls"
DartPth = "\\V1sacpdofc1\CPCTProjects\PMO\DART\F0" & XlYear &
"_DART\Dec DART 04\" & DartRef
xlApp.Worksheets("Top Sheet").Range("a1") = DartPth
xlApp.Workbooks.Open (DartPth), 0, ReadOnly = True
xlApp.ActiveWorkbook.Windows(1).Visible = False
End If
End If

With xlApp.Workbooks(DartRef).Worksheets(ShtRef)
.Cells.Replace What:="=", Replacement:="=", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
Set xlSheet = xlApp.Worksheets.Add
xlSheet.Name = ShtRef
.Cells.Copy xlApp.ActiveWorkbook.Sheets(ShtRef).Range("A1")

.Cells.Replace What:="=", Replacement:="=", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
End With
sName = Left(activeworkbook.Name, len(activeworkbook.Name)-4)
ActiveWorkbook.SaveAs FileName:="C:\Someplace\" &
sName & "_processed.xls"

--
Regards,
Tom Ogilvy

"Helen" wrote in message
...
I have a series of files that I must extract data from each week. What I'd
like to be able to do is run my VBA code against the sheet, then when I'm
finished with the sheet, save it as a different name, in a different
directory, in order to alert other users that the sheets have been

processed.

Where should I start in order to achieve my goals?

I currently use the following code to verify & open sheet;
DartRef = "CPCT " & xlmonth2 & " CDART.xls"
DartPth = "\\V1sacpdofc1\CPCTProjects\PMO\DART\F0" & XlYear & "_DART\" &
xlmonth2 & " DART 0" & XlYear & "\" & DartRef

If Dir(DartPth) < "" Then
xlApp.Workbooks.Open (DartPth), 0, ReadOnly = True
xlApp.ActiveWorkbook.Windows(1).Visible = False
Else
XLMonth = Month(Date) - 1
If XLMonth = 0 Then
XLMonth = "12"
xlmonth2 = "Dec"
XlYear = 5
DartRef = "CPCT " & xlmonth2 & " CDART.xls"
DartPth = "\\V1sacpdofc1\CPCTProjects\PMO\DART\F0" & XlYear &
"_DART\Dec DART 04\" & DartRef
xlApp.Worksheets("Top Sheet").Range("a1") = DartPth
xlApp.Workbooks.Open (DartPth), 0, ReadOnly = True
xlApp.ActiveWorkbook.Windows(1).Visible = False
End If
End If

With xlApp.Workbooks(DartRef).Worksheets(ShtRef)
.Cells.Replace What:="=", Replacement:="=", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
Set xlSheet = xlApp.Worksheets.Add
xlSheet.Name = ShtRef
.Cells.Copy xlApp.ActiveWorkbook.Sheets(ShtRef).Range("A1")

.Cells.Replace What:="=", Replacement:="=", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
End With




 
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 save error: the file or directory cannot be created dublg Excel Discussion (Misc queries) 1 September 25th 06 07:07 PM
Excel should let me sort the file directory when saving a file Beanee70 Excel Discussion (Misc queries) 0 March 14th 06 07:03 AM
Combine all text file in directory into one file. Rich[_19_] Excel Programming 8 January 21st 04 04:09 PM
How to get file name from long directory Lillian[_5_] Excel Programming 11 December 4th 03 06:49 PM
get path - save new file - same sub-directory as existing file tegger Excel Programming 2 October 21st 03 10:45 AM


All times are GMT +1. The time now is 06:36 PM.

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"