Help required in exporting data

MI man

Registered User.
Local time
Today, 06:29
Joined
Nov 23, 2008
Messages
59
Hi All,

I have a text template in word in which there are some of the places where I have to replace some of the text with the specified other.
For this, I have made a template in excel where I input the replacable words. Now how to export these replacable words from excel into the specified point in MS Word text template without affecting the font and other formatting.

Any help over this please..??
 
Hey guys...!!

I forgot to tell you that my only source is VBA.

So, if anything that I have to do, I have to do it either throught the front end (Direct in Word) or through VBA.

Any help..??
 
You could set the font and pitch to match the word doc in Excel. or you can reset the font and size in your word doc after you have changed the values. I assume you are using bookmarks.

David
 
Why on earth would you go to all this bother when you could just set up a simple mail merge or form template?
 
This is what I use to put Excel cell values into Word bookmarks. Below that code is code for Access field values to Word bookmarks. In my opinion Access is far superior for this type of thing as there is much greater flexibility in triggering the code in Access.


Code:
Set WordObj = CreateObject("Word.Application")
   Set WordDoc = WordObj.Documents.Open _
       ("C:\Letters\" & Format(Range("E25") + ".doc"))
   WordObj.Visible = True   
 
    With WordDoc.Bookmarks
     .Item("a2").Range.InsertBefore Worksheets("Sheet1").Range("A" & "" & ActiveCell.Value).Value
.Item("a3").Range.InsertBefore Worksheets("Sheet1").Range("B" & "" & ActiveCell.Value).Value
.Item("name").Range.InsertBefore Worksheets("Sheet1").Range("C" & "" & ActiveCell.Value).Value   
  
 End With

Code:
Dim WordDoc As Object
Dim WordObj As Object
Set WordObj = CreateObject("Word.Application")
   Set WordDoc = WordObj.Documents.Open("c:\Letters\AccessWord.doc")
   WordObj.Visible = True
    
  
   
   With WordDoc.Bookmarks
     .Item("a1").Range.InsertBefore Nz([Forms]![GoToWord]![Text1], "")
    .Item("a2").Range.InsertBefore Nz([Forms]![GoToWord]![Text3], "")
  .Item("a3").Range.InsertBefore Nz([Forms]![GoToWord]![Text5], "")
   .Item("a4").Range.InsertBefore Nz([Forms]![GoToWord]![Text7], "")
    .Item("a5").Range.InsertBefore Nz([Forms]![GoToWord]![Text11], "")
     .Item("a6").Range.InsertBefore Nz([Forms]![GoToWord]![Text14], "")
    
      .Item("a7").Range.InsertBefore Nz([Forms]![GoToWord]![FLName], "")
      
       .Item("a8").Range.InsertBefore Nz([Forms]![GoToWord]![Text27], "")
      
    End With
 

Users who are viewing this thread

Back
Top Bottom