Una famiglia di software per fogli di calcolo Microsoft con strumenti per l'analisi, la creazione di grafici e la comunicazione dei dati.
Ciao Mauro,
Avendo dichiarato la variable sh, sarebbe meglio sarebbe usarla!
'=========>>
Option Explicit
'--------->>
Private Declare Function FindExecutable _
Lib "shell32.dll" Alias "FindExecutableA" ( _
ByVal lpFile As String, ByVal lpDirectory As String, _
ByVal lpResult As String) As Long
'--------->>
Public Sub SelezionaPdf()
Dim wk As Workbook
Dim sh As Worksheet
Dim PageName As Variant, PageName2 As String
Const CR As String = "CR3"
Const istruz As String = "istruzioni3"
Set wk = ThisWorkbook
Set sh = wk.Worksheets(CR)
PageName = Application _
.GetOpenFilename("Text Files (*.pdf), *.pdf")
If PageName <> False Then
MsgBox "Open " & PageName
End If
If PageName = "False" Then
Exit Sub
End If
Sheets(istruz).Range("I1").Value = PageName
With sh
.Select
.Range("A:K").ClearContents
.Range("A1").Select
End With
PageName2 = "C:\temp\YourPage.pdf"
FileCopy PageName, PageName2
Call OpenPDF(PageName2)
Application.Wait (Now + TimeValue("0:00:04"))
SendKeys "^a", True
Application.Wait (Now + TimeValue("0:00:02"))
SendKeys "^c", True
Application.Wait (Now + TimeValue("0:00:05"))
SendKeys ("%fx")
AppActivate "Microsoft Excel"
wk.Activate
sh.Activate
MsgBox "Premi Ok per incollare"
'\ Nuova istruzione
DoEvents
SendKeys ("^v")
'\ Nuova istruzione
DoEvents
Sheets(istruz).Select
Range("A1").Select
'Set a Nothing delle variabili oggetto
Set sh = Nothing
Set wk = Nothing
End Sub
'--------->>
Sub OpenPDF(filename As String)
Dim ExeName As String
Dim N As Long
ExeName = String(260, 0)
N = FindExecutable(filename, vbNullString, ExeName)
ExeName = Left(ExeName, InStr(1, ExeName, vbNullChar) - 1)
Shell ExeName & " " & Chr(34) & filename & Chr(34), vbNormalFocus
End Sub
'<<=========
===
Regards,
Norman