Argument ou appel de procedure incorrect

Bonjour à tous,

J'espere que vous allez bien, je rencontre un petit probleme depuis peu de temps avec une maccro Excel qui jusqu'à présent fonctionné à merveille

"Erreur d'exécution '5': Argument ou appel de procedure incorrect

Le code:

Sub OnePaySlip()
'Initialisation de nos variables
Dim saveLocation As String
Dim rng As Range
Dim LDate As String
Dim NbrEmployees As String
Dim intBoucle As Integer
Dim employeeVal As String
Dim birthDate As String
Set fso = CreateObject("Scripting.FileSystemObject")

'On récupère le mois et l'année pour le trie dans dossiers
LDate = Date
sMonth_Name = MonthName(Month(Worksheets("PaySlip").Range("date2").Value))
sYear_Name = CStr(Year(Worksheets("PaySlip").Range("date2").Value))
birthDate = Worksheets("PaySlip").Range("birthday").Value
'On verifie si le dossier ou vont etre stocké les paies existent sinon on le créer
myPath1 = Environ("USERPROFILE") + "\Documents\PaySlip\"
myPath2 = Environ("USERPROFILE") + "\Documents\PaySlip\Societe"
myPath3 = Environ("USERPROFILE") + "\Documents\PaySlip\Societe\Temp"

    If Len(Dir(myPath1, vbDirectory)) = 0 Then
       MkDir myPath1
    End If
    If Len(Dir(myPath2, vbDirectory)) = 0 Then
       MkDir myPath2
    End If
    If Len(Dir(myPath3, vbDirectory)) = 0 Then
       MkDir myPath3
    End If

'On verifie si le dossier ou vont etre stocké les paies existent sinon on le créer
employeeVal = Range("name").Value
        Worksheets("PaySlip").Range("month").Value = "Pay Slip - " & sMonth_Name & " " & sYear_Name ' Titre Mois Année
        Worksheets("PaySlip").Range("payroll").Value = DateSerial(Year(Worksheets("PaySlip").Range("date2").Value), Month(Worksheets("PaySlip").Range("date2").Value), 1) & " to " & DateSerial(Year(Worksheets("PaySlip").Range("date2").Value), Month(Worksheets("PaySlip").Range("date2").Value) + 1, 0) 'Affiché la payroll period

        tempLocation = Environ("USERPROFILE") + "\Documents\PaySlip\Societe\Temp\" + employeeVal + ".pdf"
        Set rng = Sheets("PaySlip").Range("Fiche")
        'Save as PDF
        rng.ExportAsFixedFormat Type:=xlTypePDF, _
        Filename:=tempLocation, From:=1, to:=1

        realLocation = Environ("USERPROFILE") + "\Documents\PaySlip\Societe\" + employeeVal + " - " + sMonth_Name + ".pdf"

        convertProtected = "PDFtk """ + tempLocation + """ output """ & realLocation & """ user_pw " & birthDate

        Shell "C:\WINDOWS\System32\cmd.exe """ & convertProtected & "", vbNormalFocus

fso.DeleteFolder Environ("USERPROFILE") + "\Documents\PaySlip\Societe\Temp"
End Sub

J'ai un template de fiche de paie sur ma worksheet et ca genere automatiquement avec les bonnes dates, en pdf avec un mot de passe (librairie PDFtk).

Du coup jusqu'à présent cela fonctionnait mais j'ai une erreur sur l'execution de la commande Shell (surligné en jaune dans le debuggeur)

Shell "C:\WINDOWS\System32\cmd.exe """ & convertProtected & "", vbNormalFocus

Si quelqu'un aurait une idée Merci à vous :)

Bonjour Gamgma4K,

Si vous mettez un

Debug.Print  convertProtected

Pour moi la syntaxe n'est pas correcte

A+

Hello,

Enfaite j'ai trouvé le problème j'ai installé Office avec ce script sur quelques PC:

#Set parameters
$path = "$env:TEMP\office"
$odtsetup = "$path\officedeploymenttool.exe"
$odt = "$path\setup.exe"
$xmlpath = "$path\configuration.xml"
New-Item -Path $path -ItemType directory

#Download Office Deployment tool
$url = "microsoft.com   /en-us/   download/  confirmation.aspx  ?id=49117""
try {
    $response = Invoke-WebRequest -UseBasicParsing -Uri $url -ErrorAction SilentlyContinue
} catch {
    Throw "Failed to connect to ODT: $url with error $_."
    Break
} finally {
    $ODTUri = $response.links | Where-Object {$_.outerHTML -like "*click here to download manually*"}
    Invoke-WebRequest -UseBasicParsing -Uri $ODTUri.href -OutFile $odtsetup
}

#Create xml
$xml= @'
  <Configuration ID="7962839d-c897-4b63-8068-7b2003934f04">
    <Add OfficeClientEdition="64" Channel="Current">
      <Product ID="O365ProPlusRetail">
        <Language ID="en-us" />
        <ExcludeApp ID="Groove" />
        <ExcludeApp ID="Lync" />
        <ExcludeApp ID="Bing" />
      </Product>
    </Add>
    <Property Name="SharedComputerLicensing" Value="0" />
    <Property Name="SCLCacheOverride" Value="0" />
    <Property Name="AUTOACTIVATE" Value="0" />
    <Property Name="FORCEAPPSHUTDOWN" Value="FALSE" />
    <Property Name="DeviceBasedLicensing" Value="0" />
    <Updates Enabled="TRUE" />
    <RemoveMSI />
    <AppSettings>
      <User Key="software\microsoft\office\16.0\common\general" Name="shownfirstrunoptin" Value="1" Type="REG_DWORD" App="office16" Id="L_DisableOptinWizard" />
      <User Key="software\microsoft\office\16.0\common" Name="qmenable" Value="0" Type="REG_DWORD" App="office16" Id="L_EnableCustomerExperienceImprovementProgram" />
      <User Key="software\microsoft\office\16.0\osm" Name="enablelogging" Value="0" Type="REG_DWORD" App="office16" Id="L_EnableLogging" />
      <User Key="software\microsoft\office\16.0\firstrun" Name="disablemovie" Value="1" Type="REG_DWORD" App="office16" Id="L_DisableMovie" />
      <User Key="software\microsoft\office\16.0\firstrun" Name="bootedrtm" Value="1" Type="REG_DWORD" App="office16" Id="L_DisableOfficeFirstrun" />
    </AppSettings>
    <Display Level="None" AcceptEULA="TRUE" />
  </Configuration>
'@

$xml | Out-File $xmlpath

#extract setup.exe from odt
Start-Process -Filepath $odtsetup -ArgumentList "/quiet /extract:$path" -Wait -NoNewWindow

#run setup with xml
Start-Process -Filepath $odt -ArgumentList "/configure $xmlpath" -Wait -NoNewWindow

#add shortcuts to dekstop
Copy-Item "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Excel.lnk" "C:\Users\Public\Desktop\"
Copy-Item "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Outlook.lnk" "C:\Users\Public\Desktop\"
Copy-Item "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Word.lnk" "C:\Users\Public\Desktop\"

J'ai pris un autre PC avec une installation classique (le .exe sur l'espace utilisateur office) le code marche parfaitement.

Par contre j'ai désinstaller/reinstaller Office, Changer les clés de registre Office je n'arrive pas à revenir à une installation non bugge si quelqu'un à des suggestions

Thx

Re,

Que vient faire ce script d'installation ici, ce n'est pas du VBA !?

A+

Re,

Je sais bien c'est pour savoir si quelqu'un aurait une solution suite à mon erreur

Re,

Votre erreur n'a rien à voir avec l'installation d'office

Il faut plutôt regarder du côté de PDFtk, réinstallation à faire je pense

A+

Si si tous les PC ou j'ai installé Office avec ODT (le script) mon VBA ne marche pas, sur les PC avec une installation classique il marche et le probleme coincide avec les dates de modification.

La je teste de supprimer tous les Office folder, desinstaller full, etc mais rien n'y fait pour l'instant

Re,

Alors si vous le dites

Pour moi il faut vérifier qu'existe le "templocation" et le "realLocation"

Bah étant donné que comme je l'ai dis j'ai tésté sur un autre PC il y a 5 minutes c'est sur que le vba est ok

Rechercher des sujets similaires à "argument appel procedure incorrect"