Hi
I have Sheet.(Section A) that has text in column "E", this text would start in row 10, and could have numerous rows, say 30. I am trying to extract the text in the cells in Column E, open a template in word and insert into a bookmark. I have mastered the code to extract a cell, open the word template, and insert into a bookmark. That is where my knowledge ends.
This question is twofold.
I would like to try and understand the code to extract more than one cell in column E, it would start in r,10 and could finish in r,30.
Also i have about 10 sheets which have the same attributes with regard to same column and same cells, but obviously different text.
I have started some code but all it does is open 2 documents.
[
Sub ExportButton()
Dim objWord As Object
Dim ws As Worksheet
Set ws = ThisWorkbook.Sheets("Section A")
Set objWord = CreateObject("Word.Application")
objWord.Visible = True
objWord.Activate
objWord.Documents.Open "C:\Users\Desktop\L2Template3.docx"
With objWord.ActiveDocument
.Bookmarks("DescriptionField").Range.Text = ws.Range("E10").Value
End With
With objWord.ActiveDocument
.Bookmarks("NameField").Range.Text = ws.Range("E12").Value
End With
Set objWord = Nothing
Set ws = ThisWorkbook.Sheets("Section B")
Set objWord = CreateObject("Word.Application")
objWord.Visible = True
objWord.Activate
objWord.Documents.Open "C:\Users\Desktop\L2Template3.docx"
With objWord.ActiveDocument
.Bookmarks("StephenField").Range.Text = ws.Range("E10").Value
End With
With objWord.ActiveDocument
.Bookmarks("JohnField").Range.Text = ws.Range("E12").Value
End With
Set objWord = Nothing
End Sub
]
hope someone can help
I have Sheet.(Section A) that has text in column "E", this text would start in row 10, and could have numerous rows, say 30. I am trying to extract the text in the cells in Column E, open a template in word and insert into a bookmark. I have mastered the code to extract a cell, open the word template, and insert into a bookmark. That is where my knowledge ends.
This question is twofold.
I would like to try and understand the code to extract more than one cell in column E, it would start in r,10 and could finish in r,30.
Also i have about 10 sheets which have the same attributes with regard to same column and same cells, but obviously different text.
I have started some code but all it does is open 2 documents.
[
Sub ExportButton()
Dim objWord As Object
Dim ws As Worksheet
Set ws = ThisWorkbook.Sheets("Section A")
Set objWord = CreateObject("Word.Application")
objWord.Visible = True
objWord.Activate
objWord.Documents.Open "C:\Users\Desktop\L2Template3.docx"
With objWord.ActiveDocument
.Bookmarks("DescriptionField").Range.Text = ws.Range("E10").Value
End With
With objWord.ActiveDocument
.Bookmarks("NameField").Range.Text = ws.Range("E12").Value
End With
Set objWord = Nothing
Set ws = ThisWorkbook.Sheets("Section B")
Set objWord = CreateObject("Word.Application")
objWord.Visible = True
objWord.Activate
objWord.Documents.Open "C:\Users\Desktop\L2Template3.docx"
With objWord.ActiveDocument
.Bookmarks("StephenField").Range.Text = ws.Range("E10").Value
End With
With objWord.ActiveDocument
.Bookmarks("JohnField").Range.Text = ws.Range("E12").Value
End With
Set objWord = Nothing
End Sub
]
hope someone can help