Consulting

Results 1 to 6 of 6

Thread: Problem with save

  1. #1
    VBAX Expert
    Joined
    Jan 2005
    Posts
    574
    Location

    Problem with save

    Can anyone tell me why this is not working please

    Thanks

    Gibbo

    Dim todaysdate As Date
    Dim Customer As String
    Dim Thislocation As String
    Customer = Worksheets("Invoice").Range("B11").value
    Thislocation = thisdir
    ' Print and save Button
    Application.ScreenUpdating = False
       ActiveSheet.Copy
       Application.GetSaveAsFilename
       Application.DisplayAlerts = False
       ActiveWorkbook.Save
       ActiveWorkbook.Close
       Application.DisplayAlerts = True
       Application.ScreenUpdating = True

  2. #2
    Site Admin
    Jedi Master
    VBAX Guru Jacob Hilderbrand's Avatar
    Joined
    Jun 2004
    Location
    Roseville, CA
    Posts
    3,712
    Location
    Try this:

    Dim FName As String 
    FName = Application.GetSaveAsFilename 
    ActiveWorkbook.SaveAs FileName:=FName

  3. #3
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    It is a bit hard to say as you don't tell us what is not working, and we don't see where thisdir is defined or what ThisLocation is used for. But ...

    GetSaveAsFilename is a function, and you just run it. That is a bit pointless as it returns a value which one would normally use in the code, you don't.


    .
    ____________________________________________
    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

  4. #4
    VBAX Expert
    Joined
    Jan 2005
    Posts
    574
    Location
    wow, thanks for the extreamy quick reply

    Code works as follows

    Dim FName As String
    ' Print and save Button
       Application.ScreenUpdating = False
       Application.DisplayAlerts = False
       ActiveSheet.Copy
       FName = Application.GetSaveAsFilename
       ActiveWorkbook.SaveAs Filename:=FName
       ActiveWorkbook.Close
       Application.DisplayAlerts = True
       Application.ScreenUpdating = True
    'Print
    ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
    My only other question is that the Application.GetSaveAsFilename
    comes up with the only option in the drop down as all files, how do i default it to xls?

    Cheers

    Gibbo

    P.S. xld, sorry for being vague, long day and wasnt thinking clearly hence the poor explanation

  5. #5
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Change the filefilter to xls as shown in the VBA help (it uses txt, same principle).
    ____________________________________________
    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 Expert
    Joined
    Jan 2005
    Posts
    574
    Location
    Thankyou, just the job

    Gibbo

Posting Permissions

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