Hey everyone,
I have recently taken over a piece of work which using VBA to open a chart in excel and pastes it into a word document and re sizes it. This code used to work but is now coming up with the run time error code 5941.
The bit where it mentions 'inline shapes' is where it falls over
The person who wrote the code is no longer here and no one else in the office - including myself - knows how to fix it. here is the code:
We are truly stuck and need some assistance. I have checked and the bookmarks exist and the excel and charts are fine and in the right location.
Does anyone know what this might be?
Many thanks as always
I have recently taken over a piece of work which using VBA to open a chart in excel and pastes it into a word document and re sizes it. This code used to work but is now coming up with the run time error code 5941.
The bit where it mentions 'inline shapes' is where it falls over
The person who wrote the code is no longer here and no one else in the office - including myself - knows how to fix it. here is the code:
Code:
Public Sub AddIdaciCharts()
Dim IDACIFile As Excel.Workbook
'opens the file based on the school number workbook range
Set IDACIFile = Workbooks.Open(ThisWorkbook.Path & "\IDACI Files\335" & Range("SchoolDfE") & " idaci decile bands 2016.xlsx")
'copies the chart from the School vs LA tab and pastes into the bookmark in the word doc
IDACIFile.Sheets("School vs LA").ChartArea.Copy
wrdApp.Selection.Goto what:=wdGoToBookmark, Name:="IDACI1"
wrdApp.Selection.PasteSpecial DataType:=wdPasteBitmap, Placement:=wdInLine
wrdApp.Selection.MoveLeft unit:=wdCharacter, Count:=1, Extend:=wdExtend
With wrdApp.Selection.InlineShapes(1)
.Height = 295
.Width = 480
.Range.ParagraphFormat.Alignment = wdAlignParagraphCenter
End With
We are truly stuck and need some assistance. I have checked and the bookmarks exist and the excel and charts are fine and in the right location.
Does anyone know what this might be?
Many thanks as always
Last edited by a moderator: