Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Help with SaveAs Macro on Auto_Open

Let me give you a bit of the scenario. I have a shortcut to a template that
is on a network drive so that everyone brings up a nice blank "Daily Log".
When it is opened it saves itself as "Daily Log for <date" in a directory
called Daily Log on each individual persons personal drive on the network.
This works great until one thing occurs... they try to open the daily log
again and it sees there's already a file named "Daily Log for <that day".
(The code I have for the Auto_Open is below)

Is there a way to either, have the macro not function after its been
saved as a different file from the Template? or open the existing file
instead of trying to overwrite it?



Sub Auto_Open()

Dim myPath As String
Dim myFileName As String

On Error Resume Next
MkDir ThisWorkbook.Path & "\" & "Daily Log"

myPath = ThisWorkbook.Path & "\" & "Daily Log"

myFileName = myPath & "\" & "Daily Log for " & Format(Date, "mm_dd_yy")
& ".xls"

ActiveWorkbook.SaveAs Filename:=myFileName, FileFormat:=xlWorkbookNormal



End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,327
Default Help with SaveAs Macro on Auto_Open

Hi

If I understand this right; if it's not the template at the template
location running the do nothing ? If so try something like

If ThisWorkbook.Fullname < "F:\Whatever\Folder\EditThis\Template.xlt" Then
Exit Sub

HTH. Best wishes Harald

"Daen" skrev i melding
...
Let me give you a bit of the scenario. I have a shortcut to a template

that
is on a network drive so that everyone brings up a nice blank "Daily Log".
When it is opened it saves itself as "Daily Log for <date" in a directory
called Daily Log on each individual persons personal drive on the network.
This works great until one thing occurs... they try to open the daily log
again and it sees there's already a file named "Daily Log for <that day".
(The code I have for the Auto_Open is below)

Is there a way to either, have the macro not function after its been
saved as a different file from the Template? or open the existing file
instead of trying to overwrite it?



Sub Auto_Open()

Dim myPath As String
Dim myFileName As String

On Error Resume Next
MkDir ThisWorkbook.Path & "\" & "Daily Log"

myPath = ThisWorkbook.Path & "\" & "Daily Log"

myFileName = myPath & "\" & "Daily Log for " & Format(Date,

"mm_dd_yy")
& ".xls"

ActiveWorkbook.SaveAs Filename:=myFileName,

FileFormat:=xlWorkbookNormal



End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Help with SaveAs Macro on Auto_Open

Harald, I can't thank you enough for all the help you've given me lately.
Thats exactly what I need, but the only problem is the Template renames the
Log to Daily Log1 once it is doubleclicked. I think I can work around that
though, I'll try it and let you know how it goes.

Brilliant! Cheers!

"Harald Staff" wrote:

Hi

If I understand this right; if it's not the template at the template
location running the do nothing ? If so try something like

If ThisWorkbook.Fullname < "F:\Whatever\Folder\EditThis\Template.xlt" Then
Exit Sub

HTH. Best wishes Harald

"Daen" skrev i melding
...
Let me give you a bit of the scenario. I have a shortcut to a template

that
is on a network drive so that everyone brings up a nice blank "Daily Log".
When it is opened it saves itself as "Daily Log for <date" in a directory
called Daily Log on each individual persons personal drive on the network.
This works great until one thing occurs... they try to open the daily log
again and it sees there's already a file named "Daily Log for <that day".
(The code I have for the Auto_Open is below)

Is there a way to either, have the macro not function after its been
saved as a different file from the Template? or open the existing file
instead of trying to overwrite it?



Sub Auto_Open()

Dim myPath As String
Dim myFileName As String

On Error Resume Next
MkDir ThisWorkbook.Path & "\" & "Daily Log"

myPath = ThisWorkbook.Path & "\" & "Daily Log"

myFileName = myPath & "\" & "Daily Log for " & Format(Date,

"mm_dd_yy")
& ".xls"

ActiveWorkbook.SaveAs Filename:=myFileName,

FileFormat:=xlWorkbookNormal



End Sub




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,327
Default Help with SaveAs Macro on Auto_Open

"Daen" skrev i melding
...
Harald, I can't thank you enough for all the help you've given me

lately.

You did anyway. Cheers!
Best wishes Harald


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
Minimising the Ribbon in an Auto_Open macro Jeff Wiggins Excel Discussion (Misc queries) 3 May 9th 08 03:35 PM
Auto_Open Macro Trying to Excel Excel Discussion (Misc queries) 2 April 13th 07 07:08 AM
Can I make an Auto_open macro conditional? David M Hargrave Excel Discussion (Misc queries) 2 August 25th 06 10:26 AM
Force read-only in auto_open macro hhalle Excel Discussion (Misc queries) 0 August 20th 06 10:44 AM
Auto_Open vs. macro John Wilson Excel Programming 0 September 22nd 03 05:44 PM


All times are GMT +1. The time now is 11:25 PM.

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

About Us

"It's about Microsoft Excel"