[dba-Tech] Yet another Word question

MartyConnelly martyconnelly at shaw.ca
Wed Jul 13 12:19:18 CDT 2005


Odd I just answered a similar question on Access-L

Here is one method, it just inserts one word doc after the other.
Watch closing word down you may have several copies of word
running so check task manger processes.

You can can change insertion point to be bookmark, paragraph
or even clipboard via a search for a Text String strInsertDesc
rather than a straight character count.

     AppWord.Selection.Paste
     AppWord.ActiveDocument.Content.InsertAfter Text:=strInsertDesc


Sub CreateDocumentWord()
' Save multiple Word doc files into one.
Dim AppWord As Object
Dim InsertPosition As Long
    Set AppWord = CreateObject("Word.Application")
'empty doc to start
AppWord.Documents.Add
'copy first doc at character position
InsertPosition = AppWord.ActiveDocument.Characters.Count - 1
           Debug.Print InsertPosition
AppWord.ActiveDocument.Range.InsertFile _
      FileName:="C:\WordVBA\Copy Text to Insert in the Word Document.doc"
'copy second doc at next character position
InsertPosition = AppWord.ActiveDocument.Characters.Count - 1
           Debug.Print InsertPosition
AppWord.ActiveDocument.Range(InsertPosition).InsertFile _
      FileName:="C:\WordVBA\David.doc"
'save  outuput file
Dim strfilename As String
    strfilename = "C:\WordVBA\" & "OutputWord"
    strfilename = strfilename & Format(Now, "yyyymmddhhmmss") & ".doc"
    AppWord.ActiveDocument.SaveAs (strfilename)
Set AppWord = Nothing
End Sub

Arthur Fuller wrote:

>Assuming that Word is already opened programmatically from Access, with a
>document open, I now want to open two more files in Word. How might I do
>that. Would it simply be...
>
>    objWord.Documents.Add .... plus the name of the file, and the same again
>with the name of the other file.
>
>Arthur
>
>_______________________________________________
>dba-Tech mailing list
>dba-Tech at databaseadvisors.com
>http://databaseadvisors.com/mailman/listinfo/dba-tech
>Website: http://www.databaseadvisors.com
>
>
>  
>

-- 
Marty Connelly
Victoria, B.C.
Canada






More information about the dba-Tech mailing list