+ Reply to Thread
Results 1 to 5 of 5

Save as false.xls localized problem

Hybrid View

  1. #1
    Registered User
    Join Date
    12-29-2010
    Location
    italy
    MS-Off Ver
    Excel 2010
    Posts
    20

    Save as false.xls localized problem

    hi dudes :D

    hi have a problem with the save as macro :D

    i created that sub

    i retrieve the value of a cell and with that i create a name to pass to the save-as .

    the save as has a check to ask if overwrite or not.

    everything works fine but i have to localize the sub also for not-english excel..


    Public Sub Save_Click()
    
        On Error GoTo ErrorHandler
        
        Dim Filename As String
        Dim fileSaveName As String
        Dim note As String
        Dim overwriteFile As VbMsgBoxResult
            
        Dim TableName As Range
        Set TableName = Range("TableName")
        Filename = TableName.Value
     
         With Application
            .ScreenUpdating = False 'disable screen updating
            .EnableEvents = False 'disable events
            .Run "protectAndHide"
            .ScreenUpdating = True 'disable screen updating
            .EnableEvents = True 'disable events
        End With
                    
        ' this opens the Save As window and sets the filename and file type
        fileSaveName = Application.GetSaveAsFilename(Filename & ".xls", fileFilter:="Microsoft Excel Workbook (*.xls),*.xls")
    
        If (fileSaveName = False) Then 'User click cancel
            Exit Sub
                    
        Else 'User click ok
            If Len(Dir(fileSaveName, vbNormal)) = 0 Then 'The file not already exists
                ActiveWorkbook.SaveAs Filename:=fileSaveName 'Save file
                MsgBox "Saved as : " & vbNewLine & fileSaveName
                Exit Sub
            Else ' The file already exists, Display MessageBox if overwrite
                note = "The file already exists!" & vbNewLine & "Do you want to replace " & fileSaveName & " ?"
                overwriteFile = MsgBox(note, vbQuestion + vbYesNo, "Overwrite file?")
                If overwriteFile = vbNo Then 'No overwrite
                    Exit Sub
                Else 'yes overwrite
                    Application.DisplayAlerts = False
                    ActiveWorkbook.SaveAs Filename:=fileSaveName 'Save file
                    Application.DisplayAlerts = True
                    Exit Sub
                End If
            End If
    
        End If
    
        Exit Sub
        
    ErrorHandler:
        MsgBox "Unfortunately, an error has occurred saving the file.", vbOKOnly, "Error"
        
         With Application
            .ScreenUpdating = True 'en screen updating
            .EnableEvents = True 'en events
        End With
        Exit Sub
    End Sub

    the problem is that..
     If (fileSaveName = False) Then
            Exit Sub
    is not working...

    so i tried
    If (fileSaveName = "False") Then 
            Exit Sub
    it works only for english excels


    then i tried
     If (fileSaveName = "Falso") Then
            Exit Sub
    it works only for italian excels ..

    i could make a switch to check every "false" word in every language .. but i'm looking for a smarter idea

    is there a way to check the "false" word not localized in some language?


    please i need your help ^_^

    regards and thanks

    Jack
    Last edited by kensei; 04-11-2011 at 03:58 AM.

  2. #2
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: Save as false.xls localized problem

    This is kind of a wild guess, but try:

    Define your saveFileName as a variant instead of a string. False is equal to 0, so check if the variant in number format is equal to zero. This worked on my english version when I tested it.

    Sub text()
    
    Dim fileSaveName As Variant
    fileSaveName = Application.GetSaveAsFilename
    
    
    If (Format(fileSaveName, "0") = 0) Then 'User click cancel
            Debug.Print "Cancelled"
            Exit Sub
    Else
        Debug.Print "Saved " & fileSaveName
    End If
    
    End Sub
    Is your code running too slowly?
    Does your workbook or database have a bunch of duplicate pieces of data?
    Have a look at this article to learn the best ways to set up your projects.
    It will save both time and effort in the long run!


    Dave

  3. #3
    Registered User
    Join Date
    12-29-2010
    Location
    italy
    MS-Off Ver
    Excel 2010
    Posts
    20

    Re: Save as false.xls localized problem

    That's the smartness i was looking for

    works great, thanks a lot
    Last edited by romperstomper; 04-11-2011 at 03:09 AM.

  4. #4
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,985

    Re: Save as false.xls localized problem

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save
    Everyone who confuses correlation and causation ends up dead.

  5. #5
    Registered User
    Join Date
    12-29-2010
    Location
    italy
    MS-Off Ver
    Excel 2010
    Posts
    20

    Re: Save as false.xls localized problem

    done! thanks :D

+ 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