samu653
Goto Top

Druck Liste mit VBA

Ich habe ein script geschrieben um im Hintergrund verlinkte PDF auf dem Dokument auszudrucken.
Nun würde ich dieses Script gerne auf Multiple Clients Ausführen. Es gibt da doch ein Problem da die Client aus einer Mischung von 32 und 64 bit systemen bestehen.
Ich würde gerne wissen was ich an meinem Script umschreiben / hinzufügen muss damit es auf allen Clients einwandfrei Funktioniert.

Hier ist der bisheriger Code welcher nur auf meinem Rechner Funktioniert.

Private Sub CommandButton1_Click()
If CheckBox1 = True Then

print_mypdf ("F:\Datenaustausch\PDF\01_Projects_an_appropriate_image_and_has_a_positive_attitude_and_is_genuine_EN.pdf")
End If
If CheckBox2 = True Then
print_mypdf ("F:\Datenaustausch\PDF\02_Has_a_healthy_degree_of_self-confidence_and_exercises_self-control_EN.pdf")
End If
If CheckBox3 = True Then
print_mypdf ("F:\Datenaustausch\PDF\03_Is_willing_to_accept_change_and_adapts_well_to_new_situations_EN.pdf")
End If
If CheckBox4 = True Then
print_mypdf ("F:\Datenaustausch\PDF\04_Gets_to_grips_with_new_information_quickly_and_thoroughly_EN.pdf")
End If
If CheckBox5 = True Then
print_mypdf ("F:\Datenaustausch\PDF\05_Has_excellent_analytical_skills_EN.pdf")
End If
If CheckBox6 = True Then
print_mypdf ("F:\Datenaustausch\PDF\06_Is_innovative_and_visionary_EN.pdf")
End If

If CheckBox7 = True Then
print_mypdf ("F:\Datenaustausch\PDF\07_Communicates_proposed_solutions_logically_EN.pdf")
End If
If CheckBox8 = True Then
print_mypdf ("F:\Datenaustausch\PDF\08_Has_well-developed_conceptual_skills_EN.pdf")
End If
If CheckBox9 = True Then
print_mypdf ("F:\Datenaustausch\PDF\09_Thinks_in_an_integrated_way_EN.pdf")
End If
If CheckBox10 = True Then
print_mypdf ("F:\Datenaustausch\PDF\10_Thinks_strategically_in_a_long-term_and_profit-focused_way_EN.pdf")
End If
If CheckBox11 = True Then
print_mypdf ("F:\Datenaustausch\PDF\11_Has_well-developed_organisational_and_planning_skills_EN.pdf")
End If
If CheckBox12 = True Then
print_mypdf ("F:\Datenaustausch\PDF\12_Simplifies_ processes_and_continuously_improves_them_EN.pdf")
End If
If CheckBox13 = True Then
print_mypdf ("F:\Datenaustausch\PDF\13_Acts_in_a_disciplined_way_and_concentrates_on_the_essentials_EN.pdf")
End If
If CheckBox14 = True Then
print_mypdf ("F:\Datenaustausch\PDF\14_Gets_on_with_other_people_easily_EN.pdf")
End If
If CheckBox15 = True Then
print_mypdf ("F:\Datenaustausch\PDF\15_Expresses_themselves_well_-_verbally_and_non-verbally_EN.pdf")
End If
If CheckBox16 = True Then
print_mypdf ("F:\Datenaustausch\PDF\16_In_writing_expresses_themselves_confidently_and_in_the_right_register_EN.pdf")
End If
If CheckBox17 = True Then
print_mypdf ("F:\Datenaustausch\PDF\17_Is_a_team-player_EN.pdf")
End If
If CheckBox18 = True Then
print_mypdf ("F:\Datenaustausch\PDF\18_Listens_actively_and_responds_to_the_other_person_and_gives_constructive_feedback_EN.pdf")
End If
If CheckBox19 = True Then
print_mypdf ("F:\Datenaustausch\PDF\19_Accepts_differing_opinions_and_creates_a_sense_of_trust_EN.pdf")
End If
If CheckBox20 = True Then
print_mypdf ("F:\Datenaustausch\PDF\20_Shows_a_clear_willingness_to_lead_EN.pdf")
End If
If CheckBox21 = True Then
print_mypdf ("F:\Datenaustausch\PDF\21_Acts_quickly_and_purposefully_EN.pdf")
End If
If CheckBox22 = True Then
print_mypdf ("F:\Datenaustausch\PDF\22_Good_at_identifying_and_delegating_competences_and_responsibilities_EN.pdf")
End If
If CheckBox23 = True Then

print_mypdf ("F:\Datenaustausch\PDF\23_Makes_decisions_and_accepts_responsibility_EN.pdf")
End If
If CheckBox24 = True Then

print_mypdf ("F:\Datenaustausch\PDF\24_Is_ambitious_and_identifies_with_the_company_EN.pdf")
End If
If CheckBox25 = True Then
print_mypdf ("F:\Datenaustausch\PDF\25_Is_flexible_and_willing_to_learn_EN.pdf")
End If
If CheckBox26 = True Then
print_mypdf ("F:\Datenaustausch\PDF\26_Takes_the_initiative_and_works_independently_EN.pdf")
End If
If CheckBox27 = True Then
print_mypdf ("F:\Datenaustausch\PDF\27_Is_able_to_motivate_themselves_and_others_EN.pdf")
End If
If CheckBox28 = True Then
print_mypdf ("F:\Datenaustausch\PDF\28_Creates_an_atmosphere_of_trust_EN.pdf")
End If
If CheckBox29 = True Then

print_mypdf ("F:\Datenaustausch\PDF\29_Recognises_and_develops_potential_EN.pdf")
End If
If CheckBox30 = True Then
print_mypdf ("F:\Datenaustausch\PDF\30_Argues_convincingly_EN.pdf")
End If
If CheckBox31 = True Then
print_mypdf ("F:\Datenaustausch\PDF\31_Defends_ their_position_forcefully_EN.pdf")
End If
If CheckBox32 = True Then
print_mypdf ("F:\Datenaustausch\PDF\32_Is_assertive_EN.pdf")
End If
If CheckBox33 = True Then
print_mypdf ("F:\Datenaustausch\PDF\33_Is_emotionally_resilient_EN.pdf")
End If
If CheckBox34 = True Then
print_mypdf ("F:\Datenaustausch\PDF\34_Handles_conflict_well_EN.pdf")
End If
If CheckBox35 = True Then
print_mypdf ("F:\Datenaustausch\PDF\35_Can_deal_with_criticism_and_setbacks_EN.pdf")
End If

End Sub


Sub print_mypdf(MyFile As String)

DoEvents

Shell "C:\Program Files\Adobe\Acrobat 9.0\Acrobat\Acrobat.exe /p /h " & MyFile, vbHide

End Sub


Ich wäre SEHR dankbar, falls jemand mir Helfen könnte.

Freundliche Grüsse

Samuel Bernet

Content-Key: 155151

Url: https://administrator.de/contentid/155151

Printed on: April 18, 2024 at 16:04 o'clock

Member: bastla
bastla Nov 16, 2010 at 11:56:48 (UTC)
Goto Top
Hallo Samu653 und willkommen im Forum!

Wenn es nur um die Berücksichtigung des Ordners "Program Files" in Abhängigkeit von der BS-Version geht, dann könntest Du den Aufruf des AdobeReaders etwa so formulieren:
set WshShell = WScript.CreateObject("WScript.Shell")  
AdobePath = WshShell.ExpandEnvironmentStrings("%ProgramFiles%") & "\Adobe\Acrobat 9.0\Acrobat\Acrobat.exe"  
Shell AdobePath & " /p /h " & MyFile, vbHide  
Grüße
bastla
Member: miniversum
miniversum Nov 16, 2010 at 12:02:16 (UTC)
Goto Top
@bastla
Warum nicht einfach:
AdobePath = Environ("ProgramFiles") & "\Adobe\Acrobat 9.0\Acrobat\Acrobat.exe"   
Shell AdobePath & " /p /h " & MyFile, vbHide  
Member: bastla
bastla Nov 16, 2010 at 12:09:11 (UTC)
Goto Top
@miniversum
Warum denn einfach, wenn's auch mit VBS-Anleihen geht? face-wink

Grüße
bastla
Member: Samu653
Samu653 Nov 16, 2010 at 12:14:50 (UTC)
Goto Top
Hallo Bastla

Herzlichen Dank für die schnelle Antwort.

Sollte ich nicht den AdobePath = WshShell.ExpandEnvironmentStrings("%ProgramFiles%") & "\Adobe\Acrobat 9.0\Acrobat\Acrobat.exe"
Auf AdobePath = WshShell.ExpandEnvironmentStrings "\\Adobe\Acrobat 9.0\Acrobat\Acrobat.exe" umschreiben??
Momentan gibt es mir einen runtime error 424 an

Gruss

Samuel
Member: bastla
bastla Nov 16, 2010 at 12:20:24 (UTC)
Goto Top
Hallo Samu653!
Sollte ich nicht ...
Nur, wenn Du es noch mehr verschlimmbessern wolltest ... face-wink

Abgesehen von der, von miniversum aufgezeigten, unter VBA zur Verfügung stehenden Alternative wird es auch mit
set WshShell = CreateObject("WScript.Shell")
als erster Zeile funktionieren ...

Grüße
bastla
Member: Samu653
Samu653 Nov 16, 2010 at 12:52:20 (UTC)
Goto Top
Hallo Bastla

Das Script funktioniert!!! Herzlichen Dank.
Nun wollte ich dich doch noch Fragen wie ich das Script anpassen kann damit ich den Drucker auswählen kann.
Momentan druckt es die Dokumente einfach auf den Standard Drucker aus.

Grüsse

Samuel
Member: bastla
bastla Nov 16, 2010, updated at Oct 18, 2012 at 16:44:07 (UTC)
Goto Top
Hallo Samu653!

Für den Moment kann ich Dir nur ein paar Anhaltspunkte liefern:
  • Einen Ansatz zum Setzen des Standarddruckers hatten wir mal hier,
  • eine Suche nach "VBA" und "Druckerauswahldialog" führt Dich zB da hin, und
  • mit einem weiteren Umweg über VBS könntest Du zB auf die "EnumPrinterConnections-Methode" zurückgreifen ...

Grüße
bastla
Member: Samu653
Samu653 Nov 16, 2010 at 14:05:03 (UTC)
Goto Top
Vielen Dank Bastla
Du warst euserst hilfreich!!

Grüsse

Samuel
Member: bastla
bastla Nov 16, 2010 at 14:08:45 (UTC)
Goto Top
Hallo Samu653!
Du warst euserst hilfreich!!
Gerne face-smile (allerdings wäre ich lieber äußerst hilfreich gewesen face-wink) ...

Grüße
bastla