Solved

How do I?

Posted on 2001-06-26
7
131 Views
Last Modified: 2010-05-02
Read the following:
Private Sub Form_Load()

'Description - PFGPGP Encryption and FTP to Principal
'Created 05/08/01 by Mitchell Buford


'Environment.............

OTHRDIR = (Environ$("OTHRDIR") + "\")
Windir = (Environ$("WINDIR") + "\")

' Move old Encrypted Files to Saved.....................


Dim Today As String
Today = Format(Now, "yyyymmdd")
Dim LastMO As String
Dim LastYR As String
Dim THISYR As String
Dim THISDA As String
THISYR = Mid$(Today, 1, 4)
ThisMO = Mid$(Today, 5, 2)
THISDA = Mid$(Today, 7, 2)
LastYR = Val(THISYR)
LastMO = Val(ThisMO) - 1
If LastMO = 0 Then
   LastMO = 12
   LastYR = LastYR - 1
End If
Dim FolderName As String
FolderName = LTrim(Str(LastYR * 100 + LastMO))
gstrMsg = (FolderName)
gstrResponse = MsgBox(gstrMsg)

Name "\\wakelybdc\common\monthend\pfg\" & FolderName & "\agntrept" As "\\wakelypdc\ftp$\pfg"



If Dir("\\wakelypdc\ftp$\pfg\saved\" & FolderName, vbDirectory) = "" Then
   MkDir "\\wakelypdc\ftp$\pfg\saved\" & FolderName
End If

Name "\\wakelypdc\ftp$\pfg\agntrept.pgp" As "\\wakelypdc\ftp$\pfg\saved\" & FolderName & "\agntrept.pgp"
Name "\\wakelypdc\ftp$\pfg\commrept.pgp" As "\\wakelypdc\ftp$\pfg\saved\" & FolderName & "\commrept.pgp"
Name "\\wakelypdc\ftp$\pfg\grpstsum.pgp" As "\\wakelypdc\ftp$\pfg\saved\" & FolderName & "\grpstsum.pgp"
Name "\\wakelypdc\ftp$\pfg\grpssdet.pgp" As "\\wakelypdc\ftp$\pfg\saved\" & FolderName & "\grpssdet.pgp"

The IF statement I have for the directory, how do I do this with files?  If they are not there or not there how do I make the program skip over and go the next command instead of a runtime error.
0
Comment
Question by:mtbuford
7 Comments
 
LVL 43

Accepted Solution

by:
TimCottee earned 100 total points
ID: 6228117
If Dir("\\wakelypdc\ftp$\pfg\saved\" & FolderName, vbDirectory) = "" Then
  MkDir "\\wakelypdc\ftp$\pfg\saved\" & FolderName
End If

If Dir("\\wakelypdc\ftp$\pfg\agntrept.pgp") Then Name "\\wakelypdc\ftp$\pfg\agntrept.pgp" As "\\wakelypdc\ftp$\pfg\saved\" & FolderName & "\agntrept.pgp"
IF Dir("\\wakelypdc\ftp$\pfg\commrept.pgp") Then Name "\\wakelypdc\ftp$\pfg\commrept.pgp" As "\\wakelypdc\ftp$\pfg\saved\" & FolderName & "\commrept.pgp"
If Dir("\\wakelypdc\ftp$\pfg\grpstsum.pgp") Then Name "\\wakelypdc\ftp$\pfg\grpstsum.pgp" As "\\wakelypdc\ftp$\pfg\saved\" & FolderName & "\grpstsum.pgp"
If Dir("\\wakelypdc\ftp$\pfg\grpssdet.pgp") Then Name "\\wakelypdc\ftp$\pfg\grpssdet.pgp" As "\\wakelypdc\ftp$\pfg\saved\" & FolderName & "\grpssdet.pgp"
0
 
LVL 20

Expert Comment

by:hes
ID: 6228183
Tim

Member Name mtbuford
Date Account Created 09/17/99
Profile  
Knowledgebase Stats:    
Questions  
Questions Asked 49
Last 10 Grades Given A A A B A A A A A A  
Question Grading Record 18 Answers Graded / 19 Answers Received

And see

http://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=20141241
0
 
LVL 3

Expert Comment

by:Hornet241
ID: 6228217
I'm not sure if you want to check if the files exist in the destination you want to skip or not, or if there not in the origin

TimCottee's comment will not copy a file if it is not the the Origin Directory for the files.

this will copy only existing file

FileToCopy = Dir("\\wakelypdc\ftp$\pfg\*.pgp")
do while FileToCopy > ""
     ' Check if File is there and Delete if necessary
     if dir("\\wakelypdc\ftp$\pfg\saved\" & FolderName & "\" & FileToCopy) then
          Kill "\\wakelypdc\ftp$\pfg\saved\" & FolderName & "\" & FileToCopy
     End If
     Name "\\wakelypdc\ftp$\pfg\" & FileToCopy As "\\wakelypdc\ftp$\pfg\saved\" & FolderName & "\" & FileToCopy
     FileToCopy = Dir
Loop


0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 

Expert Comment

by:kmmanke
ID: 6228221
Add this to your code:
DocName = Dir("C:\Files\" & FileName & "." & FileType)
   
    If DocName <> "" Then
        Call StartDoc(SourceName, DocName)
    Else
        MsgBox ("No files found by the name of " & FileName & "." & FileType & " in the folder of C:\Files\")
    End If


This is the function it calls
Function StartDoc(SourceName As String, DocName As String)
    Dim FilePath
    On Error GoTo StartDoc_Error
   
    FilePath = SourceName & " C:\Files\" & DocName
    StartDoc = Shell(FilePath, vbNormalFocus)
    Exit Function
   
StartDoc_Error:
        MsgBox "Error: " & Err & " " & Error
        Exit Function
End Function
0
 
LVL 5

Expert Comment

by:gbaren
ID: 6228232
On Error Resume Next
Name "\\wakelypdc\ftp$\pfg\agntrept.pgp" As "\\wakelypdc\ftp$\pfg\saved\" & FolderName & "\agntrept.pgp"
Name "\\wakelypdc\ftp$\pfg\commrept.pgp" As "\\wakelypdc\ftp$\pfg\saved\" & FolderName & "\commrept.pgp"
Name "\\wakelypdc\ftp$\pfg\grpstsum.pgp" As "\\wakelypdc\ftp$\pfg\saved\" & FolderName & "\grpstsum.pgp"
Name "\\wakelypdc\ftp$\pfg\grpssdet.pgp" As "\\wakelypdc\ftp$\pfg\saved\" & FolderName & "\grpssdet.pgp"
0
 
LVL 5

Expert Comment

by:gbaren
ID: 6228239
Every single day there is a newbie who needs to be told:

"Do NOT post proposed answers. Comments only!"
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 6228550
mtbuford:

You have asked 49 questions within Experts-Exchange, yet only closed/awarded 19 of them, despite expert input and follow up requests to return and close.  The options at this point are:

1. Award points to the Expert who provided an answer, or who helped you most. Do this by clicking on the "Accept Comment as Answer" button that lies above and to the right of the appropriate expert's name.

2. PAQ the question because the information might be useful to others, but was not useful to you. To use this option, you must state why the question is no longer useful to you, and the experts need to let me know if they feel that you're being unfair.

3. Delete the question because it is of no value to you or to anyone else.  To use this option, you must state why the question is no longer useful to you, and the experts need to let me know if they feel that you're being unfair.

If you elect for option 2 or 3, all you need to do is post right here as a comment, and I will take care of the rest.  We also request that you review any other open questions you might have and deal with them as necessary.

PLEASE DO NOT AWARD THE POINTS TO ME.

____________________________________________

 

Hi Experts:

In the event that the Asker does not respond, I would very much appreciate your opinions as to which Expert ought to receive points (if any) as a result of this question.  Likewise, you can also suggest that I PAQ or delete the question.

Experts, please do not add further "answer" information to this question.  I will be back in about one week to finalize this question, earlier if comments received.

Thank you everyone.

Moondancer
Community Support Moderator @ Experts Exchange
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now