Toon posts:

[VBA excel] bestand open in code

Pagina: 1
Acties:
  • 137 views sinds 30-01-2008

Verwijderd

Topicstarter
ik heb een excel bestand waar ik in vba een werkbalk maak
met verschillende knoppen. 1 van die knoppen wil ik een
PDF file laten openen als hier op geklikt word.

Wie weet er wat ik bij mijn on-click procedure moet zetten?

Verwijderd

Visual Basic .NET:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
Dim PSFileName as String, PDFFileName as String, DistillerCall as String
Dim ReturnValue as Variant

'Define the path and filenames (can get the names from a cell, and add the path & extension):

PSFileName= "G:\DestinationDir\SubDir\TargetFile.PS"
PDFFileName= "G:\DestinationDir\SubDir\TargetFile.PDF"

'If the files already exist, delete them:

If Dir(PSFileName) <> "" Then Kill (PSFileName)
If Dir(PDFFileName) <> "" Then Kill (PDFFileName)

'The Sendkeys characters are the full path and filename, followed by the "Enter" key.
' These are buffered until the "print to file" screen appears:

SendKeys PSFileName & "{ENTER}", False
ActiveSheet.PrintOut , PrintToFile:=True

'Add double quotes around the PS filename and PDF filename:

PSFileName = Chr(34) & PSFileName & Chr(34)
PDFFileName = Chr(34) & PDFFileName & Chr(34)
DistillerCall = "C:\Program Files\Adobe\Acrobat 4.0\Distillr\Acrodist.exe" & _
" /n /q /o" & PDFFileName & " " & PSFileName

'Call the Acrobat Distiller to distill the PS file. ReturnValue is zero
'if the application doesn't open correctly:

ReturnValue = Shell(DistillerCall, vbNormalFocus)
if ReturnValue = 0 Then MsgBox "Creation of " & PDFFilename & "failed."


Afhankelijk van de gebruikte versie van Acrobat, verschillende de paden naar de bestanden.

[ Voor 14% gewijzigd door Verwijderd op 18-12-2003 12:58 ]


  • OZ-Gump
  • Registratie: November 2002
  • Laatst online: 14-05-2024

OZ-Gump

terug van weggeweest

Wat is er mis met een ShellExecute, waarbij je het PDF-bestand opgeeft? Windows pakt dan automatisch het met die extensie geassocieerde programma en opent het opgegeven bestand!

Zoek dus op ShellExecute en u bent op weg... ;)

My personal website


  • curry684
  • Registratie: Juni 2000
  • Laatst online: 12-05 22:23

curry684

left part of the evil twins

Verwijderd schreef op 18 december 2003 @ 12:10:
ik heb een excel bestand waar ik in vba een werkbalk maak
met verschillende knoppen. 1 van die knoppen wil ik een
PDF file laten openen als hier op geklikt word.

Wie weet er wat ik bij mijn on-click procedure moet zetten?
Jij hopelijk, jij programmeert het ding. Wij niet, wij programmeren het ding niet.

Als je een concrete vraag hebt: geen probleem. Maar 'heej schrijf mijn code eens voor me' doen we hier niet aan :Y)

Professionele website nodig?


Dit topic is gesloten.