Results 1 to 4 of 4
  1. #1
    Join Date
    Sep 2012
    Posts
    3

    Unanswered: Public Function AddDatetoFile()

    We're running this code and running into error; it highlights sfilename in the function with an error - compile error: expected sub, function or property.

    Any ideas what's wrong, we ran out of options trying to figure it out
    Thanks in advance!


    Private Sub DatingMyFiles()
    Call AddDatetoFile("\\len-storage-1\reports\dotwell\databases\Apr 2012 HIV Report- CS Previous-" & sDate & ".xlsx")
    End Sub

    Public Function AddDatetoFile()
    Dim sAppPath As String
    Dim sDate As String
    Dim sFileName As String

    sAppPath = "\\len-storage-1\reports\dotwell\databases"
    sDate = Replace(FormatDateTime(Now() - 30, vbShortDate), "/", ".")
    sFileName = sAppPath & "Previous - " & sDate & ".xlsx"

    ActiveWorkbook.SaveAs FileName:="Apr 2012 HIV Report- CS.xlsx"
    sFileName , FileFormat:= _
    xlNormal, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False _
    , CreateBackup:=False

    End Function

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    and what are the actual values of sAppPath and sDate

    place a watch/breakpoint on the sub call code and step through the code to make certain the values are what you think they are.
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Sep 2012
    Posts
    3
    Thanks for your reply, however, I'm not sure what you mean...?

    Doesn't this define the value?

    sAppPath = "\\len-storage-1\reports\dotwell\databases"
    sDate = Replace(FormatDateTime(Now() - 30, vbShortDate), "/", ".")

  4. #4
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    no
    thats the VBA code that creates your runtime values
    I want to see the actual values not the vba code
    I'd rather be riding on the Tiger 800 or the Norton

Posting Permissions

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