+ Reply to Thread
Results 1 to 2 of 2

SaveAs file lost

  1. #1
    Aaron
    Guest

    SaveAs file lost

    Hello,

    I have to following code which does a save as and saves the file in the
    directory listed.

    Sub SaveWithDate()
    '
    Dim wb As Workbook
    Dim ws As Worksheet
    Dim varVal As Variant
    Dim strFileName As String

    Set wb = ActiveWorkbook
    Set ws = wb.Worksheets("$ Reference")
    varVal = ws.Range("C2").Value

    If IsDate(varVal) Then
    strFileName = "Glue Sched_" & Format(CStr(varVal), "mm-dd-yyyy") &
    ".xls"
    Else
    strFileName = "Glue Sched_" & Format(CStr(Date), "mm-dd-yyyy") &
    ".xls"
    End If
    ChDir "\\Lan1\Supervisor\Departments\Foam\SCHEDULING\Old Schedules\"
    ActiveWorkbook.SaveAs Filename:=strFileName


    Set wb = Nothing
    Set ws = Nothing

    End Sub

    The part am not understanding is that when I run my workbook and this macro
    from my computer, it works perfect and saves the file in the listed
    directory. When a fellow employee ran this, it saved the file to my docs
    under his profile. I know he has access to the above directory, so I don't
    understand what might be causing that. It's almost like it automatically
    changes directories again when it performs the SaveAs. Any ideas??

  2. #2
    Gary L Brown
    Guest

    RE: SaveAs file lost

    Instead of...
    ChDir "\\Lan1\Supervisor\Departments\Foam\SCHEDULING\Old Schedules\"
    ActiveWorkbook.SaveAs Filename:=strFileName
    try...
    ActiveWorkbook.SaveAs Filename:="\\Lan1
    \Supervisor\Departments\Foam\SCHEDULING\Old Schedules\"
    & strFileName

    HTH,
    --
    Gary Brown
    gary_brown@ge_NOSPAM.com
    If this post was helpful, please click the ''Yes'' button next to ''Was this
    Post Helpfull to you?''.


    "Aaron" wrote:

    > Hello,
    >
    > I have to following code which does a save as and saves the file in the
    > directory listed.
    >
    > Sub SaveWithDate()
    > '
    > Dim wb As Workbook
    > Dim ws As Worksheet
    > Dim varVal As Variant
    > Dim strFileName As String
    >
    > Set wb = ActiveWorkbook
    > Set ws = wb.Worksheets("$ Reference")
    > varVal = ws.Range("C2").Value
    >
    > If IsDate(varVal) Then
    > strFileName = "Glue Sched_" & Format(CStr(varVal), "mm-dd-yyyy") &
    > ".xls"
    > Else
    > strFileName = "Glue Sched_" & Format(CStr(Date), "mm-dd-yyyy") &
    > ".xls"
    > End If
    > ChDir "\\Lan1\Supervisor\Departments\Foam\SCHEDULING\Old Schedules\"
    > ActiveWorkbook.SaveAs Filename:=strFileName
    >
    >
    > Set wb = Nothing
    > Set ws = Nothing
    >
    > End Sub
    >
    > The part am not understanding is that when I run my workbook and this macro
    > from my computer, it works perfect and saves the file in the listed
    > directory. When a fellow employee ran this, it saved the file to my docs
    > under his profile. I know he has access to the above directory, so I don't
    > understand what might be causing that. It's almost like it automatically
    > changes directories again when it performs the SaveAs. Any ideas??


+ 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