[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

File Renaming Issue

Posted on 2008-10-07
9
Medium Priority
?
219 Views
Last Modified: 2013-11-27
Scenario:

Directory full of Word Files that have patient dictation that is transcribed by centralized transcription.  I want to import the text into another MS SQL database.  I am accomplishing this using an Access DB intermediary, because I am most familiar with this.

My problem is that I want to rename each file once it has been imported so I don't have to re-import each time and then check for duplicates.  I wrote that routine and it is awfully slow!!!!

Here is the code that I have so far.  You will see that the rename is comm'ed out since it gives me an error.

Any help is appreciated.

Troyo
Public Function Grabdata()
Dim wdDoc As Word.Document
    Dim cn As New ADODB.Connection
    Dim rs As New ADODB.Recordset
    Dim F
    Dim A
    
    Dim strPath As String
    
    
    Set wdDoc = Nothing
    Set wdApp = Nothing
 
    Dim strFile As String
    Dim myFullFile As String
    strPath = "X:\Shared\WPCWW\"
    strFile = Dir(strPath, vbDirectory)
    Do While strFile <> ""
    If strFile <> "." And strFile <> ".." Then
     
    'MsgBox "got this far"
     
    '************* Start Repeating Section ***************
    Set wdApp = New Word.Application
    wdApp.Visible = False
    myFullFile = strPath & strFile
    'MsgBox strPath & strFile
        
    Set wdDoc = wdApp.Documents.Open(myFullFile)
 
    
 
    DoCmd.OpenForm "frmImport", acNormal, , , acFormAdd
    
    
    Forms!frmImport![Dict] = wdDoc.Range.Text
    wdApp.Quit
    DoCmd.Close acForm, "frmImport"
    
    
    
    MsgBox "pause"
    
    
    myFullFile1 = strPath & "*" & strFile
    
    
    'Name myFullFile As myFullFile1
    
 
        'Kill myFullFile
    End If
    strFile = Dir()
    'MsgBox strFile
    
    Loop
End Function

Open in new window

0
Comment
Question by:toverholt
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
9 Comments
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 22660003
don't use a wild character as part of your file name

'   myFullFile1 = strPath & "*" & strFile   '<< this is the one giving errorthe
     
    myFullFile1 = strPath & "Imp_" & strFile

    'Name myFullFile As myFullFile1
0
 

Author Comment

by:toverholt
ID: 22660502
Tried that...  Great idea by the way....

Gives me a Path/File Error.

0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 22660569
then check your path ? is it correct

msgboxt myFullFile &" > " & myFullFile1
0
Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

 

Author Comment

by:toverholt
ID: 22660688
Changed to:

 myFullFile1 = "X:\Shared\WPCWW\Imported\aaa_" & strFile
   
    MsgBox myFullFile & " > " & myFullFile1
   
    Name myFullFile As myFullFile1
   


This works.  If I comment out the msgbox line, it errors.  Is this a lag issue with processing? Any way I can add a pause, so I don't have to hit enter 2000 times?

Also, I chose to move to a seperate directory as well.  I may not change the name, but just move the file.

Troyo
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 22660757
do you have the folder Imported created?
X:\Shared\WPCWW\Imported\

if you want to move the file, use

filecopy  sourcePath & strFile, destinationPath & strFile
0
 

Author Comment

by:toverholt
ID: 22660802
Changing back to original plan of renaming


    myFullFile1 = "X:\Shared\WPCWW\aaa_" & strFile
   
    MsgBox myFullFile & " > " & myFullFile1
   
    Name myFullFile As myFullFile1
   

Works with MsgBox not without it.

Troyo
0
 

Author Comment

by:toverholt
ID: 22661766
Works Most of the Time with the msgBox statement in there.  It must be a timing issue waiting for Word to close.
0
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 2000 total points
ID: 22661833
place this codes in a regular module

option compare database
option explicit

Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)




___________


myFullFile1 = "X:\Shared\WPCWW\aaa_" & strFile
   
   sleep 1000  ' just modify the value
   
    Name myFullFile As myFullFile1

0
 

Author Closing Comment

by:toverholt
ID: 31503852
Thanks for your continued help via dialogue.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

649 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