Hello, I am working on a project to copy/paste a single cell from various unique excel sheets to their correlating files.
This is what I have so far:
What I am looking for is code to not only paste it into word, but into the last table of the document.
So far I have come up with using this:
or this:
I have had trouble implementing either of these to run effectively. Any solutions?
This is what I have so far:
Code:
Sub CopyandPaste()
Dim myfile
Range("j2").Select
Selection.Copy
myfile = Application.GetOpenFilename(, , "Browse for Document")
Dim wdapp As Word.Application
Set wdapp = CreateObject("Word.Application")
wdapp.Visible = True
Dim wddoc As Word.document
Set wddoc = wdapp.Documents.Open(myfile)
End Sub
So far I have come up with using this:
Code:
Sub PasteToWord()
Dim rangetocopy As Range
Set rangetocopy = Range("j2").CurrentRegion
Dim wordapp As Word.Application
wordapp.Visible = True
Dim worddoc As Word.document
Set worddoc = wordapp.Documents.Add
rangetocopy.Copy
worddoc.Words(1).PasteExcelTable False, False, False
End Sub
Code:
selection.GoTo What:=wdGoToLine, Which:=wdGoToFirst, Count:= 39, Name:="" Selection.Find.ClearFormattingWithSelection.Find
.text=""
.Replacement.Text=""
.Forward=True
.Wrap=wdfindcontinue
.Format=false
.MatchCase=False
.MatchWholeWord=False
.MatchWildCards=False
.MatchSoundslike=False
.MatchAllWordForms=False
End With