On a recent gig I ran into a problem where my PDF converter would not handle (straight to Excel) the PDF created by a Mac
But the converter could put the PDF file into Word - well, I then tried to copy paste it manually - and after several attempts finally succeeded, but it was tricky. I got a picture of the first page pasted several times, and - It was on a gig, so I wanted to automate
Well, I looked at the Word forum and found some code by macropod (Bless him/her), so plagiarizing from macropod and using the recorder, I came up with this routine:
And - it seems to be pretty slick!![]()
Sub CopyDocx() 'Note: this code requires a reference to the Word object model 'The input Word Document must be named WCon.docx (see N below) 'The Active sheet in Excel must be in the folder where you want your output to be 'As you run this you need to consult the task manager to see whether any app is waiting Dim P As String, N As String: P = ActiveWorkbook.Path & "\": N = "WCon.docx" Dim wdApp As Word.Application: Set wdApp = New Word.Application Dim wdDoc As Word.Document: Set wdDoc = wdApp.Documents.Open(FileName:=P & N) wdApp.Selection.EndKey Unit:=wdStory, Extend:=wdExtend wdApp.Selection.Copy wdApp.DisplayAlerts = wdAlertsNone wdDoc.Close SaveChanges:=False wdApp.Quit Set wdDoc = Nothing: Set wdApp = Nothing Application.ScreenUpdating = True Range("A1").Select: ActiveSheet.Paste End Sub
![]()
Bookmarks