Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2003
    Posts
    22

    Unanswered: I do NOT want it to overwrite.

    How do I do so that Access doesn't copy if file2 already exsists?

    Dim myPath As String
    Dim file1 As String
    Dim file2 As String
    Dim x

    myPath = CurrentProject.Path & "\2a\"
    file1 = myPath & "manuf-artno.doc"
    file2 = myPath & [2a2_manuf] & "-" & [2a1_databaseID] & ".doc"

    FileCopy file1, file2

    x = Shell("winword """ & file2 & """", vbMaximizedFocus)

    cheers!
    lowtek.

  2. #2
    Join Date
    Jul 2003
    Location
    Amsterdam, Nederland
    Posts
    450

    Wink Nice 1

    Comment : '"' = ' & " & ' (see the Line with .FileName = )
    Try this 1 :

    Dim myPath As String
    Dim file1 As String
    Dim file2 As String
    Dim x

    myPath = CurrentProject.Path & "\2a\"
    file1 = myPath & "manuf-artno.doc"
    file2 = myPath & [2a2_manuf] & "-" & [2a1_databaseID] & ".doc"

    Set fs = Application.FileSearch
    With fs
    .LookIn = "myPath"
    .FileName = "[2a2_manuf] & '"'-'"' & [2a1_databaseID] & '"'.doc'"'"
    If .Execute(SortBy:=msoSortbyFileName, _
    SortOrder:=msoSortOrderAscending) > 0 Then
    MsgBox "There were " & .FoundFiles.Count & _
    " file(s) found."
    For i = 1 To .FoundFiles.Count
    MsgBox .FoundFiles(i)
    Next i
    Else
    MsgBox "There were no files found."



    FileCopy file1, file2

    x = Shell("winword """ & file2 & """", vbMaximizedFocus)

    End If
    End With

Posting Permissions

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