Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Other Office > Word VBA
Word VBA Discuss using VBA to program Word.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Word VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old February 3rd, 2007, 11:07 PM
Registered User
Join Date: Jul 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Open document, Open second doc and copy to first

so far I have the following.
    'check whether to create a new word instance or use an existing session
    WordRunning = IsWordRunning
    If WordRunning Then
        Set WordApp = GetObject(, "Word.Application")
        Set WordApp = New Word.Application
        End If

    'open up the reference document
    Set WordDoc = WordApp.Documents.Open("C:\Database\25KgPowder\Bas e.doc") '
    With WordApp
    .Visible = True
    .WindowState = wdWindowStateNormal
    End With

    'check on the access form which controls are active
    'open that section document
    'copy it
    'and then paste it after the book mark in the reference document

    If (Me![Section11]) = True Then
    'do something
    Set WordDoc =
WordApp.Documents.Open("C:\Database\25KgPowder\Sec tion11.doc")
    'copy contents for pasting into original document

    'close the "Section11" document as not required anymore


    'paste this section to the template
    'bring original document to focus
    'locate the bookmark and paste section11
    Set WordDoc = WordApp.Documents.Open("C:\Database\25KgPowder\Bas e.doc")
    Set WordDoc = WordApp.ActiveDocument
    Set WordRng = WordDoc.GoTo(what:=wdGoToBookmark, NAME:="frmBookmark")

    'do something
    End If

The if statements continue for another 10 conditions.

I am automating from access 2000.
I open an existing document and if the access controls on the form are true,
add sections to the existing document.
How do I copy the second documents contents and add it to the original
document after the bookmark in the original document?
Then I want to close the second documnets session and move on to add
another section if the next access control is true.
Old March 7th, 2007, 02:47 AM
sks sks is offline
Registered User
Join Date: Mar 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts

Hi there,

I know reading/writing of document in VB, .Net
But due to lack of exact file format, and unavailaibilty of enough documentation for Doc file format
i dont know how to extract the Section, bulletin in Word Doc.

I want to search a particular text in a Word Document, & i need to extract the session, or bulletin (in number format) for e.g. if my text to be searched is "TEstData123"
& if it is present in say in section 1.2, 3.2.1,, 5.1 .... and so on
So wherever it is present i need to extract all these sections(1.2, 3.2.1,, 5.1 .... ) as an output

So would any one plz help me in doing so

Eagerly waiting for help
Thanks in Advance :)

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to Open A Word Doc... using ASP .net nikks9 ASP.NET 1.0 and 1.1 Professional 8 March 31st, 2015 03:45 AM
how to open a Doc from java raju_vv Servlets 1 May 28th, 2007 07:24 AM
Help need to geneate word doc in open office satyakishore Servlets 0 March 16th, 2006 04:14 AM
PROBLEM TO OPEN XML DOC IN 98SE chanti XML 0 August 9th, 2004 06:42 AM
How to open a .DOC file with MS-Word ? sherbir Servlets 0 July 26th, 2004 02:39 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.