Hi there
I have a small problem. Could you tell me / advice how to assign a Range to Bookmark from Sheet1 in below case ?
thanks!
I have a small problem. Could you tell me / advice how to assign a Range to Bookmark from Sheet1 in below case ?
thanks!
Code:
Sub SomeSub()Dim r As Integer
Dim wdApp As Word.Application
Dim doc As Word.Document
Dim wkbCRMExt As Workbook
Dim wksCRMExt As Worksheet, wksCRM As Worksheet
Set wksCRM = ActiveSheet
Set wkbCRMExt = Workbooks.Open(Environ("UserProfile") & "\Desktop\CRM.xlsx")
Set wksCRMExt = wkbCRMExt.Sheets(1)
Set wdApp = New Word.Application
Set doc = wdApp.Documents.Open(Environ("UserProfile") & "\" & ThisWorkbook.Sheets("Path").Cells(1))
With ThisWorkbook.Worksheets("CRM2")
[B]With ThisWorkbook.Worksheets("Sheet1")
[/B]
For r = 1 To 5
doc.Bookmarks(wksCRM.Cells(r, "A").Value).Range.Text = wksCRMExt.Cells(r, "B").Value
doc.Bookmarks(.Cells(r, "A").Value).Range.Text = .Cells(r, "B").Value
[B]doc.Bookmarks(.range A1:A20)[/B]
Next
End With
doc.SaveAs2 Environ$("UserProfile") & "\Desktop\Doc1.docx"
doc.Close False
End Sub