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

Jerry,

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
conMDB.Errors.Clear
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
Else
  If objWord Is Nothing Then
    Set objWord = New Word.Application
  Else
    Set objWord = GetObject(, "Word.Application")
  End If
  objWord.Documents.Add
  Set pWordDoc = objWord.ActiveDocument
  pRS.MoveFirst
  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
    pRS.MoveNext
  Wend
End If 'recordset exists?
pRS.Close
Set pRS = Nothing

pWordDoc.SaveAs (sWorkingDocName)
pWordDoc.Close

Set pWordDoc = Nothing
Set objWord = Nothing

HTH



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