[AccessD] MS Word - Copy and Paste contents of compound IFmergefield...

Shamil Salakhetdinov shamil at smsconsulting.spb.ru
Thu Jun 19 17:40:46 CDT 2008


Hello Edward,

Thank you for your response.

I have got the subject task done this way (VB.NET - quick & dirty but worked
well for me):

    Private Shared Sub ExtractEmbeddedFields2( _
         ByVal wapp As Word.Application, _
         ByVal wdoc As Word.Document, _
         ByVal fld As Word.Field)
        Dim rng As Word.Range
        wdoc.Fields.ToggleShowCodes()
        fld.Select()
        rng = wapp.Selection.Range
        fld.code.Select()

        wapp.Selection.Copy()
        wdoc.Fields.ToggleShowCodes()
        fld.Select()
        rng = wapp.Selection.Range
        rng.Collapse(Word.WdCollapseDirection.wdCollapseStart)
        fld.Delete()
        wapp.Selection.Paste()
    End Sub

I would be thankful if somebody gives more elegant solution here...

Thank you.

--
Shamil

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Edward S Zuris
Sent: Friday, June 20, 2008 2:53 AM
To: 'Access Developers discussion and problem solving'
Subject: Re: [AccessD] MS Word - Copy and Paste contents of compound
IFmergefield...


 Maybe this will help.

 One clue is to turn on the MS Word Macro recorder
 for Word 2000 and analyze some Word VBA for a task.
 That and Google I was able to teach myself on how
 to do the following.

 = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
 = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
         Concatenate Word Document files in Access 2000 VBA
 = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
 = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =


    ' *****************************************************
    '   Merge Boiler Plate file Info
    '
    sTmp1 = Trim$(rsBoil![zPath] & " ")
    sTmp2 = Trim$(rsBoil![zFileName] & " ")
    sTmp0 = sTmp1 & "/" & sTmp2

    ' *****************************************************
    '   Let Customer know what is going on
    '
    DoCmd.Echo True, "  Processing Boiler Plate:  " & sTmp2 & "   " &
CStr(Now())

    ' *****************************************************
    '   Concatenate *.doc files, adding new sections
    '   to the bottom of the new word document
    '
    objWd1App.Selection.InsertFile FileName:=sTmp0, Range:="", _
        ConfirmConversions:=False, Link:=False, Attachment:=False


 = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
 = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
           Stuffing data in a form field / Word Bookmark
 = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
 = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =


    ' *****************************************************
    '   Get Data to merge with a Bookmark \ Form Field
    '
    sBookData = ""
    sBookMark = ""
    sBookMark = rsBook![BookMark]
    sBookData = rsBook![ShowInDoc]

    ' *****************************************************
    '   Jump to the desired Bookmark
    '
    objWd1App.Selection.GoTo What:=wdGoToBookmark, Name:=sBookMark

    ' ************************************************
    '   Stuff data into the desired Bookmark
    '
    sBookData = sBookData & Space(1)
    objWd1App.Selection.TypeText Text:=CStr(sBookData)

 = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
 = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =



-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com]On Behalf Of Shamil
Salakhetdinov
Sent: Thursday, June 19, 2008 6:37 AM
To: 'Access-D'
Subject: [AccessD] MS Word - Copy and Paste contents of compound IF
mergefield...


Hi All,

I have got stuck here - I have to do the following in VBA code

Context
=======
- I have an MS Word document with IF Merge field having other MS Word fields
as its content

Task
====
- Copycat contents of the compound IF merge field including all
(sub-)fields, formats etc. but do not copy "parent" IF merger field

=========

It should be possible to do simple way somehow as far as I may guess -
trying to find this simple solution here but not yet found it so far...

Any hints, tips & tricks would be very welcome here!

Thank you.

--
Shamil





--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com

-- 
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com




More information about the AccessD mailing list