Results 1 to 4 of 4
  1. #1
    2 Star Lounger
    Join Date
    Oct 2005
    Location
    Calgary, Alberta
    Posts
    205
    Thanks
    0
    Thanked 1 Time in 1 Post

    removing ' ' from varible in VBA (xls 2007)

    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

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: removing ' ' from varible in VBA (xls 2007)

    Does it work better if you use

    txtSaveName = Format(Range("txtSaveName"), "yyyymmdd hhnnss")

  3. #3
    2 Star Lounger
    Join Date
    Oct 2005
    Location
    Calgary, Alberta
    Posts
    205
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: removing ' ' from varible in VBA (xls 2007)

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

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: removing ' ' from varible in VBA (xls 2007)

    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?

Posting Permissions

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