Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

My Files Are Playin Hide-And-Go-Seek

Status
Not open for further replies.

Fallenwing

Programmer
Aug 8, 2003
13
CA
I have the following code. In my opinion after I select the ChDir the file should be saved to that directory, on the network in our v:\. I looked for these files but they did not show up there. To my surprise I found them hiding out in C:\WINNT\Personal. Why are they going there?

Sub LifeSaver()
'
' LifeSaver Macro
' Macro recorded 25/08/2003 by Adam Kroeker
'
' Choosing the PO Name
' If PO Name Is Specialty ie. Cornie 09
If Range("PoName").Value > 1000000 Then
President = Range("PoName").Value
' If PO Name Is Mcleod or Vidir PO #
Else: President = Range("PoName").Value & " " & Range("Supplier").Value
End If
' Directory to Go To
If Range("Machine").Value = "Mill" Then ChDir "v:\stock\po receiving\mill file"
If Range("Machine").Value = "Harvester" Then ChDir "v:\stock\po receiving\harvester file"
ActiveWorkbook.SaveAs (President)
MsgBox ("File Saved As" & " " & President)
'
End Sub
 
Hi,
ChDir does not do what you are expecting it to do. You need to specify the Path...
Code:
Sub LifeSaver()
    Dim sPath As String
'
' LifeSaver Macro
' Macro recorded 25/08/2003 by Adam Kroeker
'
'   Choosing the PO Name
'   If PO Name Is Specialty ie. Cornie 09
    If Range("PoName").Value > 1000000 Then
        President = Range("PoName").Value
    '   If PO Name Is Mcleod or Vidir PO #
    Else
        President = Range("PoName").Value & " " & Range("Supplier").Value
    End If
'   Directory to Go To
    Select Case Range("Machine").Value
        Case "Mill"
            sPath = "v:\stock\po receiving\mill file"
        Case "Harvester"
            sPath = "v:\stock\po receiving\harvester file"
    End Select
    ActiveWorkbook.SaveAs (sPath & "\" & President)
    MsgBox ("File Saved As" & " " & sPath & "\" & President)
'
End Sub
Hope this helps :)

Skip,
Skip@TheOfficeExperts.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top