Obrnil sem se na tale forum v upanju na rešitev mojega problema ki se že vleče kakšen mesec. Torej, imam podatkovno bazo z pdf datotekami (v dropdown menijih) za katere sem ustaril gumb "print" ter "tiskalnik", namen prvega gumba je da mi odpre pdf datoteko ter jo avtomatsko sprinta, drugi pa izbira tiskalnika. Problem sem se spravil rešiti z makroti katere sem uspešno našel ter jih implementiral v office, zdaj mi pa nikakor ne uspe to spraviti k delovanju tako da me zanima kje sem naredil napako da mi gumba ne funkcionirata (gumb print ob pritisku sicer deluje, vendar ko dodam gumb ter macro "tiskalnik" mi napiše "error 424" ter gumb "print" neha delovati - ob pritisku ni nobenega učinka).
Za lažjo predstavo prilagam slike ter macro kodo:
https://dl.dropboxusercontent.com/u/455 ... ffice1.jpg
https://dl.dropboxusercontent.com/u/455 ... ffice2.jpg
Macro gumba "print":
Koda: Izberi vse
Sub printPDFfiles()
'******************************************
'CHECK IF A PRINTER IS SELECTED..
'******************************************
zPrinter = [chosenPrinter] 'fetch value from named cell
If zPrinter = "" Then 'CAN'T HAVE A BLANK ENTRY, SO..
zPrinter = ActivePrinter 'e.g. "hp LaserJet 1320 PCL 5 on Ne04:"
zPosition = Application.Find(" on ", zPrinter) '<< look for " on " in
zPrinterName = Left(zPrinter, zPosition - 1) '<< removes the " on Ne04:"
[chosenPrinter] = zPrinterName '<< printer name, without port
'[chosenPrinter] = ActivePrinter '<< printer with port address
End If 'end of test for no printer selection
'******************************************
'ChDrive "E" '<< if your files are on a different drive!
'NOTE:Example below uses Adobe Reader, but apply to Acrobat as well.
'If you are using Acrobat, substitute Acrobat.exe in place of AcroRd32.exe
'on the command line.
'NOTE:
'/s=don't show splash screen
'/n=new instance
'/h=minimised window
'/t=print to default printer; or use /t <filename> <printername> <drivername> <portname>
'CHECK YOUR ADOBE READER VERSION, AND USE CORRECT PATH..
zProg = "C:\Program Files (x86)\Adobe\Reader 10.0\Reader\AcroRd32.exe"
'zProg = "C:\Program Files\Adobe\Reader 11.0\Reader\AcroRd32.exe"
'******************************************
'FETCH NUMBER OF FILES TO PRINT..
'******************************************
zCount = L7 'fetch value from named cell; # of PDF files
With ActiveSheet.Shapes("Drop Down 64").ControlFormat 'Izberem trenutno vrednost iz seznama za vsak seznam boš moral ustvariti svoj gumb, če hočeš da deluje.
vIzbraniPredmet = .List(.Value) 'zapišem ime datoteke v spremenljivko vIzbraniPredmet
'MsgBox (vIzbraniPredmet)
End With
vSplosnaPot = "c:\test\Nove\" 'Pot mora biti na tvojem kompu enaka kot tukaj.
vIzbraniPredmet = """" & vSplosnaPot & vIzbraniPredmet & """" ' V spremenljivko zapišem pot do dokumenta.. Vsi tej narekovaji so tukaj zato ker imaš presledek v imenih datotek.
'vIzbraniPredmet = """c:\Nove\3830046990075.pdf"""
MsgBox vIzbraniPredmet
'zLastRow = [a65536].End(xlUp).Row 'find last row in column [A]; e.g. 15
'temp = "a1:a" & zLastRow 'e.g. "a1:a15"
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'For Each cell In Range(temp) 'loop through all entries in range
zFile = vIzbraniPredmet 'fetch filename from cell
vTest = "*.pdf" & """"
'MsgBox vTest
If zFile Like vTest Then 'check it is a pdf file type
Shell (zProg & " /n /h /t " & zFile) 'execute command to print the pdf document
End If 'end of test for pdf file type
'Next 'process nect file in list
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
End Sub
Koda: Izberi vse
Sub selectPrinter()
Application.Dialogs(xlDialogPrinterSetup).Show (ActivePrinter)
zPrinter = ActivePrinter 'e.g. "hp LaserJet 1320 PCL 5 on Ne04:"
zPosition = Application.Find(" on ", zPrinter)
zPrinterName = Left(zPrinter, zPosition - 1) '<< removes the " on Ne04:"
[chosenPrinter] = zPrinterName '<< printer name, without port
'[chosenPrinter] = ActivePrinter '<< printer with port address
End Sub
Hvala za vso pomoč!