sendkey ne fonctionne pas

herve62

XLDnaute Barbatruc
Supporter XLD
Bonsoir
Est-il normal que les Sendkeys pour imprimer ne fonctionnent pas ? j'ai fait un test avec word
L'appli et le fichier s'ouvrent bien jusque Imprimer et ?..plus rien
Code:
Acro = "C:\Program Files\microsoft office\office14\winword.exe"
    sFichier = "C:\DATA\word_data\blagues1.doc"
    Shell sAcro & " " & sFichier, vbNormalFocus
    Sleep 500
    'Application.SendKeys "^p", True
    Application.SendKeys "{TAB}"
    Application.SendKeys "{ENTREE}"
Pourtant j'ai bien vu que suite "Imprimer" il fallait faire un TAB pour aller sur le bouton Imprimer et ensuite Entrée
 

herve62

XLDnaute Barbatruc
Supporter XLD
Bon jour ; Slt JM
En fait comme tout le début fonctionne je n'ai mis que les séquences Sendkeys qui posent Pb
Code:
sPages = "1"
    Set Clip = New MSForms.DataObject
    Clip.Clear
    Clip.SetText sPages, 1
    Clip.PutInClipboard

    sAcro = "C:\Program Files\microsoft office\office14\winword.exe"
    sFichier = "C:\DATA\word_data\blagues1.doc"
    Shell sAcro & " " & sFichier, vbNormalFocus ' J'ai bien le fichier à l'écran

    Sleep 500

    Application.SendKeys "^p", True       'Pour aller au menu IMPRIMER  OK , mais la SUB ne fait plus rien ci-dessous
    Application.SendKeys "{TAB}", True ' Pour focus du bouton Imprimer
Application.SendKeys "{ENTER}", True ' Action 
    Application.SendKeys "%g", True
    Application.SendKeys "^v", True

    Application.SendKeys "{ENTER}", True

    Sleep 500

    KillAcrobatReader
    Set Clip = Nothing
Je remets l'ensemble
 

Staple1600

XLDnaute Barbatruc
Bonjour le fil, le forum

@herv62
Depuis que j'ai lu ceci, une nuit d'octobre sans lune d'une année bissextile ;)
SendKeys Warning
The SendKeys method simulates keystrokes that you would manually input in the active window.
Use with caution, because it can have unexpected results.
WARNING:
You should only use the SendKeys Method if no other option is available,
because it can cause problems, if the wrong window is active when the code runs.
Bah, je suis resté en WARNING

Maintenant, je me demande bien pourquoi tu passes par Excel pour Imprimer un *.doc ou *.pdf
Et surtout pourquoi tu utilises AcrobatReader
(car Office 2010 sait enregister un *.docx ou un *.xlsx en PDF tout seul comme un grand)
 

herve62

XLDnaute Barbatruc
Supporter XLD
Re
Salut JM
Je dois faire un petit truc genre "menu" ou l'on choisi ses fichiers à imprimer sans que les personnes ne connaissent le chemin
Donc ayant vu des exemples , j'ai pensé à l'utiliser aussi
Il y a un fil sur un site ou le gars explique avec ou sans Acrobate Pro ! mais je retrouve pas !!
car Office 2010 sait enregister un *.docx ou un *.xlsx en PDF tout seul comme un grand
Mes fichiers existent déjà en Pdf !!
You should only use the SendKeys Method if no other option is available,
because it can cause problems, if the wrong window is active when the code runs.
If not .... too bad ! I'll use an other way
 

Discussions similaires

Statistiques des forums

Discussions
311 725
Messages
2 081 947
Membres
101 849
dernier inscrit
florentMIG