+ Reply to Thread
Results 1 to 3 of 3

Naming A WorkBook To Be Saved.

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    06-24-2009
    Location
    SCOTLAND
    MS-Off Ver
    Excel Version 2308
    Posts
    151

    Naming A WorkBook To Be Saved.

    I've tried to include the following code along side strDestName so that it saves the workbook as today's date using
    & " " & Format(Now(), "dd-mm-yy")
    but there must be a syntax error somewhere.

    Here's the original code
    Dim strDestName As String:  strDestName = "SaveTest.xlsx"
        Dim strDestPath As String:  strDestPath = Environ("UserProfile") & "\Desktop\"
        
        Application.ScreenUpdating = False
        
        Dim wbSource As Workbook:   Set wbSource = ActiveWorkbook
        Dim wsActive As Worksheet:  Set wsActive = wbSource.ActiveSheet
        Dim wbDest As Workbook:     Set wbDest = Workbooks.Add
        wbDest.SaveAs Filename:=strDestPath & strDestName

    Eventually, what I'd like to acheive is for the strDestName to be named with the text input by the user into a particular cell or better still a text box control, followed by todays date.


    As I only have a basic grasp of coding, VBA, if anyone is kind enough to help out it would be great if comments were added into the coding with a brief explanation of what the codes doing.

  2. #2
    Forum Contributor
    Join Date
    05-09-2009
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    315

    Re: Naming A WorkBook To Be Saved.

    Your code works fine for me.

    Are you able to save files to your desktop?

  3. #3
    Forum Contributor
    Join Date
    06-24-2009
    Location
    SCOTLAND
    MS-Off Ver
    Excel Version 2308
    Posts
    151

    Re: Naming A WorkBook To Be Saved.

    Quote Originally Posted by mojo249 View Post
    Your code works fine for me.

    Are you able to save files to your desktop?
    Yes, I can save to my desktop but as soon as I try to incorporate Format Now etc the coding errors!!!

    Can you show me exactly how you incorporated the additional coding as no matter which way I add it I can't get it to work?

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1