LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Macro save as from Template

I have an Excel document that gets saved on a daily basis. I have it working
except when I save the worksheet as a tempalte it ignores the unc path it is
set to save to and saves it to my documents instead. I think it is because
when you oepn up the template it appends the name of it with a number 1, then
2, and so on. How do I change this code to just save it as "DAR_and then the
Date from Cell B4.xls"

Public Sub SaveAsDate()

Dim fDate As String
Dim fName As String
Dim Pos As Long
Dim blValid As Boolean
Dim fPath As String
Dim fVerify As String

With ActiveSheet.Range("B4")
If Not IsEmpty(.Value) Then
If IsDate(.Value) Then
blValid = True
fDate = Format(.Value, "yyyy-mm-dd")

With .Parent.Parent
Pos = InStr(1, .Name, ".", vbTextCompare)
If Pos 0 Then
fName = Left(.Name, Pos - 1)
fName = .Name
fPath = "\\pcfile\shared\operations\security\DAR by
dates\"
Else

End If

.SaveAs fPath & "DAR" & "_" & fDate & ".xls"
MsgBox _
prompt:="File saved successfully!", _
Buttons:=vbInformation, _
Title:="File was saved!"
End With
End If


End If
End With

If Not blValid Then MsgBox _
prompt:="No date found in Date field, file not saved!", _
Buttons:=vbCritical, _
Title:="File NOT saved!"

End Sub

 
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
Save as Template janey New Users to Excel 2 March 2nd 10 05:13 PM
When you hit Save on a template, how can you save as worksheet? cwgirl1982 Excel Worksheet Functions 1 September 4th 08 11:18 PM
don't save macro results in template Kate[_2_] Excel Programming 2 May 22nd 06 09:08 PM
Save macro in template ? David Excel Programming 3 August 12th 03 12:29 AM
Can I save a macro in a template? David Excel Programming 1 August 6th 03 03:17 AM


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