+ Reply to Thread
Results 1 to 3 of 3

Save Workbook

Hybrid View

Guest Save Workbook 02-03-2006, 01:50 PM
Guest Re: Save Workbook 02-05-2006, 03:55 PM
Guest Re: Save Workbook 02-05-2006, 06:20 PM
  1. #1
    Juan
    Guest

    Save Workbook

    Hi there,
    have following code:
    ChDir "M:\"
    ActiveWorkbook.SaveAs Filename:= _
    Application.InputBox("Enter Save as File Name") & ".xls" _
    , FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
    ReadOnlyRecommended:=False, CreateBackup:=False
    works fine but is there a way to disable the Close button in the box? If I
    click on it it saves the file as False. Also, if I click on Cancel button it
    saves as False. So what I want is that if the user clicks on accident on the
    Close button that nothing happens and if they click on Cancel button to mayve
    have a message saying Must Type File Name. This way it will force the users
    to put somethin instead of the file saving as False.
    Any ideas?
    Really appreciate.
    Juan


  2. #2
    Crowbar via OfficeKB.com
    Guest

    Re: Save Workbook

    Don't know your level of programming but not create a new userform and do the
    following

    place to buttons on it, one for saving and one to cancel

    on this form insert a textbox for people to enter the save file data in

    then insert this code into the userform and its problem solved as it works
    fine on my system

    Private Sub CommandButton1_Click()

    Filename = TextBox1.Value

    If TextBox1.Value = "" Then
    MsgBox "please enter a name for the file"
    Else

    ChDir "C:\"
    ActiveWorkbook.SaveAs Filename:="" & Filename & ".xls", FileFormat:
    =xlNormal, Password:="", WriteResPassword:="", _
    ReadOnlyRecommended:=False, CreateBackup:=False
    UserForm1.Hide

    End If

    End Sub

    Private Sub CommandButton2_Click()
    UserForm1.Hide
    End Sub

    let me know how you get on

    --
    Message posted via http://www.officekb.com

  3. #3
    Tom Ogilvy
    Guest

    Re: Save Workbook

    Dim fName as Variant
    Dim cnt as Long
    ChDrive "M"
    ChDir "M:\"
    cnt = 0
    do
    fname = Application.GetSaveAsFileName(fileFilter:= _
    "Excel Files (*.xls), *.xls)
    cnt = cnt + 1
    if cnt > 3 then exit sub
    loop while fName = False

    ActiveWorkbook.SaveAs Filename:= _
    fName, _
    FileFormat:=xlNormal)


    --
    Regards,
    Tom Ogilvy



    "Juan" <Juan@discussions.microsoft.com> wrote in message
    news:F096CC58-3E66-4281-A884-B70A67CB808A@microsoft.com...
    > Hi there,
    > have following code:
    > ChDir "M:\"
    > ActiveWorkbook.SaveAs Filename:= _
    > Application.InputBox("Enter Save as File Name") & ".xls" _
    > , FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
    > ReadOnlyRecommended:=False, CreateBackup:=False
    > works fine but is there a way to disable the Close button in the box? If I
    > click on it it saves the file as False. Also, if I click on Cancel button

    it
    > saves as False. So what I want is that if the user clicks on accident on

    the
    > Close button that nothing happens and if they click on Cancel button to

    mayve
    > have a message saying Must Type File Name. This way it will force the

    users
    > to put somethin instead of the file saving as False.
    > Any ideas?
    > Really appreciate.
    > Juan
    >




+ 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