Results 1 to 9 of 9

Define name -variable- by saving as

Threaded View

  1. #1
    Registered User
    Join Date
    02-03-2010
    Location
    Holland
    MS-Off Ver
    Excel 2003
    Posts
    12

    Define name -variable- by saving as

    Hi!

    I am looking for a solution to define a name by saving as.
    I think I'm almost there, but can't find the part where i can name it.

    In steps:
    1) Define the path and the name of the current file as string - to delete extension (=.csv)
    2) Save current file as current name with .xls in folder where is current file saved before.

    This is a part of my code - the part that is neccesary to see what I am doing:

    'Naam van het bestand opnieuw definiëren, om extensie te wissen
        Dim myOriginalFileNameToXls As String
        Dim myFilePath As String
        Dim myOriginalFileNameForSaving As String
        Dim myFileName As String
            myFilePath = ActiveWorkbook.FullName
            myOriginalFileNameToXls = Replace(myFilePath, ".csv", ".xls")
            myFileName = ActiveWorkbook.Name
            myOriginalFileNameForSaving = Replace(myFileName, ".csv", "")
                
    ' Bestand opslaan als excelbestand met nieuwe naam
       myOriginalFileNameForSaving = Application.GetSaveAsFilename(Title:="Bestand opslaan als:", _
        FileFilter:="Microsoft Office excel-werkmap(*.xls),*.xls")
    
        ' Als er geen naam kan worden ingevuld, wordt het opslaan afgebroken
        If myOriginalFileNameForSaving = False Then Exit Sub
        ' Er wordt normaal-gesproken automatisch de orginele bestandsnaam ingevuld
        If LCase$(Right$(myOriginalFileNameForSaving, 4)) <> ".xls" Then myOriginalFileNameForSaving = myOriginalFileNameForSaving & ".xls"
        ' Als er geen naam aan wordt gegeven en toch op ok wordt gedruk wordt het de "oude" naam
        ActiveWorkbook.SaveAs Filename:=myFilePath, FileFormat:=xlNormal, _
             Password:="", WriteResPassword:="", _
             ReadOnlyRecommended:=False, CreateBackup:=False
    The comment is in Dutch, but I think the code is readable...

    Is there someone who can help me out?

    Best regards,

    Brigitte
    Last edited by Brie; 02-16-2010 at 10:29 AM.

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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