I'm trying to PasteSpecial an enhanced metafile into a Word bookmark, in-line with the text (as opposed to floating, which seems to be the default). Specifically, my Word macro opens an Excel doc, copies a range of cells, and pastes into Word. I know there's a wdInline
parameter, but I learned that that only works with an OLE object, unfortunately.
The only thing I've come across online is the idea of using "Shapes" - specifically, to use the InlineShape
object - but I haven't found a way to alter my code to make that work.
Dim objExcel As New Excel.Application
Dim wb As Excel.Workbook
Dim uniqueIdentifier As String
Dim numRows As Long
Dim excelPath As String
Prompt1:
excelPath = InputBox("Enter directory/path to Excel Interface Catalogue")
If excelPath <> "" Then
Prompt2:
uniqueIdentifier = InputBox("Enter the interface's Unique Identifier")
uniqueIdentifier = UCase(uniqueIdentifier)
If uniqueIdentifier <> "" Then
Set wb = objExcel.Workbooks.Open(excelPath)
wb.Sheets("API Data Fields").Range("G8").Value = uniqueIdentifier *[**Excel function populates the cells referenced in next line**]*
numRows = (wb.Sheets("API Data Fields").Range("J8").Value) + 10
wb.Sheets("API Data Fields").Range(wb.Sheets("API Data Fields").Cells(10, 7), wb.Sheets("API Data Fields").Cells(numRows, 10)).EntireRow.AutoFit
wb.Sheets("API Data Fields").Range(wb.Sheets("API Data Fields").Cells(10, 7), wb.Sheets("API Data Fields").Cells(numRows, 10)).Copy
ActiveDocument.Bookmarks("FieldDefinition").Range.PasteSpecial DataType:=wdPasteEnhancedMetafile