I have a new workbook based on a template that is opened during a procedure, and I want to copy specific cells from an open workbook to cells in the new workbook. But the copy and paste does not seem to be working, not sure where I am running into difficulty. The code just runs through with no copy/paste happening. An example of one of the copy/paste transactions is here.
Dim wbk as Workbook
Dim TxtBk as Workbook
Dim TmpBk as Workbook
Set wbk = ThisWorkbook
Set TxtBk = ActiveWorkbook
' Get path from worksheet
fromPath = wbk.Sheets("Instructions").Range("A20").Value
' Make sure there is a backslash at the end of the from path
If Right(fromPath, 1) <> "\" Then fromPath = fromPath & "\"
' Open new file based on template
Set TmpBk = Workbooks.Add(fromPath & "UST37.xltx")
' Move data from parsed file to template
' Sheet OAA
' Running Date
TxtBk.Sheets("OAA").Activate
Range("D4").Copy
TmpBk.Sheets("OAA").Activate
Range("G4").PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False ````
TmpBk is the new workbook based on the template, and TxtBk is the source workbook, which is open. what am I missing? Thanks...
TmpBk.Sheets("OAA").Range("G4").Value = TxtBk.Sheets("OAA").Range("D4").ValueDebug.Print TxtBk.Name, TmpBk.Name.