Hi all,
I was ondering if I could get some help. I am trying to find a way of transferring data from a word document into specific cells in excel. I have previously transferred data from excel to word using the following method:
Code
Private Sub CommandButton5_Click()
Dim objWord As Object
Dim ws As Worksheet
Dim strFileName As String
Set ws = ThisWorkbook.Sheets("Online Form")
Set objWord = CreateObject("Word.Application")
objWord.Visible = True
objWord.Documents.Add
objWord.Documents.Open "C:\Documents" ' change as required
With objWord.ActiveDocument
.Bookmarks("Book1").Range.Text = ws.Range("J21").Value
.Bookmarks("Book2").Range.Text = ws.Range("B9").Value
.Bookmarks("Book3").Range.Text = ws.Range("B11").Value
Display More
I wrongly assumed if you switch it around a bit like the following, it would do the job but this wasn't the case:
Code
Private Sub CommandButton1_Click()
Dim objWord As Object
Dim ws As Worksheet
Set ws = ThisWorkbook.Sheets("Pre")
Set objWord = CreateObject("Word.Application")
objWord.Visible = True
oobjWord.Documents.Open "C:\Documents" ' change as required
With objWord.ActiveDocument
ws.Range("A2").Value = .Bookmarks("Book2").Range.Text
Display More
However, this has not worked. It opens the document and I don't get an error message but nothing seems to actually transfer...
Any ideas? of maybe a different code that might actually word?
Thanks in adavance for your help.
Cheers,