• removing ‘ ‘ from varible in VBA (xls 2007)

    Home » Forums » AskWoody support » Productivity software by function » MS Excel and spreadsheet help » removing ‘ ‘ from varible in VBA (xls 2007)

    Author
    Topic
    #448582

    Hi loungers,

    I am having an issue with saving my workbook because the save name is getting ” put before the name and after because of how I am declaring the varible txtSaveName does anyone have a solution for this?

    my code is below

    Sub SaveProposal()

    Dim LastSaved
    Dim txtSaveName

    LastSaved = Range(“LastSaved”).Value

    If LastSaved = “” Then
    txtSaveName = Range(“txtSaveName”).Value
    ActiveWorkbook.SaveAs Filename:= _
    txtSaveName, _
    FileFormat:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False
    Range(“LastSaved”).Value = Now()
    Else

    ActiveWorkbook.Save
    Range(“LastSaved”).Value = Now()
    End If
    End Sub

    Viewing 0 reply threads
    Author
    Replies
    • #1097356

      Does it work better if you use

      txtSaveName = Format(Range(“txtSaveName”), “yyyymmdd hhnnss”)

      • #1097359

        no for some reason when I goto the directory the file type in unreconized, when I goto Properties the name has “savename”

        • #1097361

          You should add an extension to the file name.
          Can you explain what your code is supposed to do and what the ranges mentioned in the code contain?

    Viewing 0 reply threads
    Reply To: removing ‘ ‘ from varible in VBA (xls 2007)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: