Hi,

I am a bit new to VBA, I figured out how to open a word document from xl vba
by browsing online but I am facing hard time in searching for a particular
text in the word document and updating it with a particular cell from my xl
spreadsheet.

*Dim wrdDoc2 As Word.Document
        Set wrdDoc2 = wrdApp.Documents.Open("c:\temp\xyz.docx")

        With wrdDoc2
            .Selection.HomeKey Unit:=wdStory   '** getting an error here
saying object does not support this property or method  but this code I
copied from word by recording a macro*
*            .Selection.Find.ClearFormatting  ** 'getting an error here
saying object does not support this property or method  but this code I
copied from word by recording a macro*
*            .Selection.Find.Replacement.ClearFormatting
            With .Selection.Find
                .Text = "[Date]"
                .Replacement.Text =
Trim(Workbooks("Contacts.xlsx").Sheets(1).Range(dateC & i).Value)
                .Forward = True
                .Wrap = wdFindContinue
                .Format = False
                .MatchCase = False
                .MatchWholeWord = False
                .MatchWildcards = False
                .MatchSoundsLike = False
                .MatchAllWordForms = False
            End With
            .Selection.Find.Execute Replace:=wdReplaceAll
        End With*

Please let me know what is the correct way to code this.

I am basically searching for "[Date]"  in word file and replacing all
"[Date]" values in word doc with a cell value from xl spread sheet.

Please pass me on some code if you had worked on handling word from xl vba,
it would be really helpful or me.

Thanks in advance for your help, I really appreciate it.

Thanks,
Srikanth

-- 
----------------------------------------------------------------------------------
Some important links for excel users:
1. Follow us on TWITTER for tips tricks and links : 
http://twitter.com/exceldailytip
2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310
3. Excel tutorials at http://www.excel-macros.blogspot.com
4. Learn VBA Macros at http://www.quickvba.blogspot.com
5. Excel Tips and Tricks at http://exceldailytip.blogspot.com
 
To post to this group, send email to excel-macros@googlegroups.com

<><><><><><><><><><><><><><><><><><><><><><>
HELP US GROW !!

We reach over 7000 subscribers worldwide and receive many nice notes about the 
learning and support from the group.Let friends and co-workers know they can 
subscribe to group at http://groups.google.com/group/excel-macros/subscribe

Reply via email to