Here is my code so far. I am returning an error on Selection.HomeKey (wdStory) w/ "Object variable or with block variable not set"
Help would be greatly appreciated! I believe I am almost there it successfully opens the file and copies the first cell I want 2,2 but then errors out.
Sub TheBigBoy()
'
' TheBigBoy Macro
'
'
ThisDocument.Select 'start in this document
'Workbooks.Open FileName:="C:\Users\David\Desktop\PRG Files\Values.xlsx"
Dim wdApp As Object
Dim wdDoc As Object
Set wdApp = CreateObject("Excel.application")
wdApp.Visible = True
Set wdDoc = wdApp.Workbooks.Open(FileName:="C:\Users\David\Desktop\PRG Files\Values.xlsx")
'Business Name
Workbooks("Values.xlsx").Sheets("Sheet1").Select
ActiveSheet.Cells(2, 2).Copy
ThisDocument.Select 'return to this document
Selection.HomeKey (wdStory)
Selection.MoveUp Unit:=wdScreen
Selection.MoveDown Unit:=wdLine, Count:=3
Selection.HomeKey Unit:=wdLine
Selection.MoveRight Unit:=wdCharacter, Count:=30
Selection.PasteAndFormat (wdFormatPlainText)
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.MoveUp Unit:=wdScreen, Count:=1
'Lots
wdDoc.Activate 'switch to source workbook
Workbooks("Values.xlsx").Sheets("Sheet1").Activate
ActiveSheet.Cells(2, 3).Copy
ThisDocument.Activate 'return to this document
Selection.HomeKey Unit:=wdStory
Selection.MoveDown Unit:=wdLine, Count:=3
Selection.HomeKey Unit:=wdLine
Selection.MoveDown Unit:=wdLine, Count:=4
Selection.MoveRight Unit:=wdCharacter, Count:=2
Selection.HomeKey Unit:=wdLine
Selection.MoveRight Unit:=wdCharacter, Count:=9
Selection.Paste
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.MoveUp Unit:=wdScreen, Count:=1
'End date invoice paid through
wdDoc.Select 'switch to source workbook
Workbooks("Values.xlsx").Sheets("Sheet1").Select
ActiveSheet.Cells(2, 4).Copy
ThisDocument.Select 'return to this document
Selection.HomeKey Unit:=wdStory
Selection.MoveDown Unit:=wdLine, Count:=14
Selection.HomeKey Unit:=wdLine
Selection.MoveDown Unit:=wdLine, Count:=1
Selection.HomeKey Unit:=wdLine
Selection.MoveRight Unit:=wdCharacter, Count:=23
Selection.PasteAndFormat (wdFormatPlainText)
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.MoveUp Unit:=wdScreen, Count:=1
'Amount received
wdDoc.Select 'switch to source workbook
Workbooks("Values.xlsx").Sheets("Sheet1").Activate
ActiveSheet.Cells(2, 5).Copy
ThisDocument.Activate 'return to this document
Selection.HomeKey Unit:=wdStory
Selection.MoveDown Unit:=wdLine, Count:=17
Selection.HomeKey Unit:=wdLine
Selection.MoveRight Unit:=wdCharacter, Count:=51
Selection.PasteAndFormat (wdFormatPlainText)
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.MoveUp Unit:=wdScreen, Count:=1
End Sub
Bookmarks