Consulting

Results 1 to 8 of 8

Thread: Solved: I want to go to "File Save As" as soon as openned

  1. #1
    VBAX Regular
    Joined
    Jul 2008
    Posts
    43
    Location

    Solved: I want to go to "File Save As" as soon as openned

    Is there a way to go to "File Save As" as soon as a file is openned? What I want is as soon as a template is chosen the first thing it does is come back and ask to be saved.
    Perhaps a better plan would be to have a macro which would save the file as a date when selected and run as soon as the template was openned?
    Last edited by kisinana; 07-19-2008 at 10:20 PM.

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    How is the template being opened, via code, or just noram EXcel selection?

    And is it reallay a template, an xlt?
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Regular
    Joined
    Jul 2008
    Posts
    43
    Location
    It is a normal template .xlt. What I have been looking at is when the file is openned it comes up as an xls version of my template. I have put a seperate button on the toolbar for "save as" and then the file name and date can be entered.
    What I was looking at doing was changing the "save as" to a small macro that writes the filename with the date and then saves it.
    I looked through the archives last night and found a post of yours to do with workbook event code that may be able to perform this. I haven't tried that yet.
    Putting it in as workbook event code will it effect other applications?

  4. #4
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Change "Test1" by substituting with "template name1". Save in ThisWorkbook module of your template.

    [VBA]
    Private Sub Workbook_Open()
    If ActiveWorkbook.Name = "Test1" Then
    Application.Dialogs(xlDialogSaveAs).Show
    End If
    End Sub
    [/VBA]
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  5. #5
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    I think you can add the code to the Workbook_Open of the template, with some appropriate checks to ensure it doesn't run a second time. and use GetSaveAsFilename with a pre-loaded name as a prompt.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  6. #6
    VBAX Regular
    Joined
    Jul 2008
    Posts
    43
    Location
    I will try those out tonight. When saving by file name and wanting it to be file name present date, I think I just add ()now to it or ()today?

  7. #7
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    You add Date. Formatting as below allows file names to be sorted in date order.

    [vba]
    ActiveWorkbook.SaveAs "C:\Test " & Format(Date,"yy-mm-dd") & ".xls"
    [/vba]
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  8. #8
    VBAX Regular
    Joined
    Jul 2008
    Posts
    43
    Location
    Thanks Guys
    For all your help. You have made a bunch of my buddies very happy.
    I was able to write most of the code I needed to run this golf scoring program, but you made it possible for the non computer types to now use the program when I am not there.
    I may later this fall refine it a little more, but for the rest of the summer we will use what I have written.
    We have a Tuesday night hackers and everyone who makes it throws in a couple of dollars. The program randomly pairs golfers and gives a winning order based on their combined scores and entry number. If an odd number play a ghost player is produced with a score that is an average of all who played that night. All this just for the chance at winning a sleeve of balls.
    Hi tech for a fun night.
    Thanks Kisinana
    I will mark this post as solved tomorrow.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •