ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Excel to input fields into a Word Form (https://www.excelbanter.com/excel-worksheet-functions/152718-excel-input-fields-into-word-form.html)

ArmsteR

Excel to input fields into a Word Form
 
Good afternoon all,

I have an excel problem I could do with some direction with.

Basically This is a work in progress but once this one piece is sorted I can manipulate it to replicate down....

We have an excel spreadsheet that has information such as site name, site code, etc etc etc. the corresponding value for these we need adding to a MS Word template, then saving and the saved location copied back into excel...

The bit I can't do at the moment is how do you take the information from excel into word? the code below is the initial setup i have to do this but can't think of how to start the import bit...

The word form text fields have bookmarks called Author, sitetext, reftext etc which are located in cells A1, B1 and C1 respectively or workbook "EntryForm"


Code:
Sub Word1()
'
' WORD1 Macro
' Opens an instance of MS Word and then opens the document Below to be confirgured
'
ActiveWindow.Visible = False
Windows("Form test.xls").Activate
Set WordApp = CreateObject("Word.Application")
WordApp.Visible = True
WordApp.Documents.Open "E:\Marks form control\ch23\siteform.doc"


' After document is open the next stage is to perform your alterations





Set WordDoc = Nothing
Set WordApp = Nothing

End Sub




any helps or pointers would be appreciated

ArmsteR

Quote:

Originally Posted by ArmsteR (Post 534199)
Good afternoon all,

I have an excel problem I could do with some direction with.

Basically This is a work in progress but once this one piece is sorted I can manipulate it to replicate down....

We have an excel spreadsheet that has information such as site name, site code, etc etc etc. the corresponding value for these we need adding to a MS Word template, then saving and the saved location copied back into excel...

The bit I can't do at the moment is how do you take the information from excel into word? the code below is the initial setup i have to do this but can't think of how to start the import bit...

The word form text fields have bookmarks called Author, sitetext, reftext etc which are located in cells A1, B1 and C1 respectively or workbook "EntryForm"


Code:
Sub Word1()
'
' WORD1 Macro
' Opens an instance of MS Word and then opens the document Below to be confirgured
'
ActiveWindow.Visible = False
Windows("Form test.xls").Activate
Set WordApp = CreateObject("Word.Application")
WordApp.Visible = True
WordApp.Documents.Open "E:\Marks form control\ch23\siteform.doc"


' After document is open the next stage is to perform your alterations





Set WordDoc = Nothing
Set WordApp = Nothing

End Sub




any helps or pointers would be appreciated






Ok here is what i've got now




Code:

Sub Word1()
 
    Dim WordApp As Object
    Dim SaveAsName As String
   
' Opens an instance of MS Word and then opens the document Below to be confirgured
'
   
    Sheets("EntryForm").Select
Range("B1").Select
Selection.Copy

   
    ActiveWindow.Visible = False
    Windows("Form test.xls").Activate
    Set WordApp = CreateObject("Word.Application")
    WordApp.Visible = True
    WordApp.Documents.Open "E:\Marks form control\siteform.doc"
WordApp.Selection.PasteSpecial Link:=False, Placement:=Bookmarks("Sitetext"), DisplayAsIcon:=False
' WordApp.ActiveDocument.Bookmarks("Sitetext").Range
   

   
    Set WordDoc = Nothing
    Set WordApp = Nothing
 
End Sub

this wont function any ideas why ?


All times are GMT +1. The time now is 09:54 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com