VBA: Open file with same name than sheet is named & user can select sheets what to copy

Pätkis

New Member
Joined
Jan 30, 2019
Messages
11
Hi,

I have a macro, which actives certain sheet and then open pdf file, which information is copied to this certain sheet. For every day there is one sheet and one file, which needs to be copied.
Is it possible to open pdf file with same name than sheet is named? How could I do it so that user could select days what to copy to excel?


Sub pdf_To_Excel_Adobe2()

Dim myWorksheet As Worksheet
Dim adobeReaderPath As String
Dim pathAndFileName As String
Dim shellPathName As String
Dim fileName As String


Sheets("2").Select

'Opens day 2 and copies data from PDF
Set myWorksheet = ActiveWorkbook.Worksheets("2")
With myWorksheet
.Range("A:M").Clear
End With

adobeReaderPath = "C:\Program Files (x86)\Adobe\Acrobat DC\Acrobat\Acrobat.exe"
pathAndFileName = ActiveWorkbook.Path & "\2.pdf"
shellPathName = adobeReaderPath & " """ & pathAndFileName & """"

Call Shell( _
pathname:=shellPathName, _
windowstyle:=vbNormalFocus)

Application.Wait Now + TimeValue("0:00:02")

SendKeys "%vpc"
SendKeys "^a"
SendKeys "^c"

Application.Wait Now + TimeValue("0:00:05")

With myWorksheet
.Range("a1").Select
.PasteSpecial Format:="Text"
End With

Call Shell("TaskKill /F /IM Acrobat.exe", vbHide)
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.

Forum statistics

Threads
1,214,429
Messages
6,119,433
Members
448,897
Latest member
ksjohnson1970

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top