Automated file name processing... 
Author Message
 Automated file name processing...


I am using an Access database to hold information about
constituant Word documents.  The code that I posted is
only a small portion of the routine I am using.

I create an ADODB.Recordset object and read through an
Access query that contains the "names" of all of the
documents that I wish to compile in to a single file.

Here is a quick summary of what I am doing:

sSQL = "SELECT * from qryCheckList"
Set pRS = New ADODB.Recordset
pRS.CursorLocation = adUseServer
pRS.Open sSQL, conMDB, adOpenStatic, adLockReadOnly
If (pRS.BOF) And (pRS.EOF) Then
  MsgBox "No documents available!", _
         vbOKOnly + vbExclamation, _
         "Nothing to process.  Exiting."
  Exit Sub
  If objWord Is Nothing Then
    Set objWord = New Word.Application
    Set objWord = GetObject(, "Word.Application")
  End If
  Set pWordDoc = objWord.ActiveDocument
  While (Not pRS.EOF)
    sSourceFileName = pRS.Fields("SOURCEFILENAME").Value
    If (sys_IsFileExists(sSourceFileName) = True) Then
      pWordDoc.Parent.Selection.EndKey 6
      pWordDoc.Parent.Selection.InsertFile sSourceFileName
    end if  'make sure file exists!!!
    pWordDoc.Parent.Selection.EndKey 6
End If 'recordset exists?
Set pRS = Nothing

pWordDoc.SaveAs (sWorkingDocName)

Set pWordDoc = Nothing
Set objWord = Nothing


Sun, 27 Mar 2005 04:33:00 GMT  
 [ 1 post ] 

 Relevant Pages 

1. How to get a Unique File Name for Automated Export

2. Word VBA automated save file name

3. Automating file downloads - pasing user names and passwords

4. Find Process by process name

5. Obtain File Names for VB Process

6. Automate Process

7. Automating the Setup Process

8. Automating Account Creation Process?

9. * Automating Process

10. Automate right-click...Properties...Hide process

11. can VB automate processes?

12. Automating a repetitive process in Excel


Powered by phpBB® Forum Software