Solved

How do I?

Posted on 2001-06-26
7
133 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
String manipulation in Visual Basic 7 59
Add a task in Outlook from access 11 35
Using an encrypted  value to decrypt and display contents in vb6 9 49
Child Form in front 4 37
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

919 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

16 Experts available now in Live!

Get 1:1 Help Now