Excel sheet to PDF Macro = security question

D

douglascfast

All,

I found this piece of code on the group:

Sub PrintPDF()

Dim PSFileName As String
Dim PDFFileName As String
PSFileName = "D:\MyDoc.PS"
PDFFileName = "D:\MyDoc.pdf"

' Print the Excel range to the postscript file
Dim MySheet As Worksheet
Set MySheet = ActiveSheet

MySheet.PrintOut copies:=1, preview:=False, _
ActivePrinter:="Acrobat Distiller", printtofile:=True, collate:=True, _
prtofilename:=PSFileName

' Convert the postscript file to .pdf

Dim myPDF As PdfDistiller
Set myPDF = New PdfDistiller
myPDF.FileToPDF PSFileName, PDFFileName, ""

End Sub

This runs fine under Admin permissions. BUt does not under a users. I
have granted full read / write access to the folder where Adobe sits,
but with no luck.

Can someone tell me how the distiller works and what permissions the
user would need to execute this?

Doug
 
T

Tom Ogilvy

do you have distiller defined as a printer under the ID that fails?

If so, select it manually.

then in the immediate window in the VBE do

? Application.ActivePrinter
and see what the string is. Does it match your code?
 
D

douglascfast

Tom,

I do not have that set up. But I dont see how I would set the
distiller as a printer. Waht I have is the Adobe PDF as a printer (and
my bad for not posting the one I am working with) is
ActivePrinter:="Adobe PDF on Ne01:"

This is in my print list. But the code fails on the lines
Dim myPDF As PdfDistiller
Set myPDF = New PdfDistiller

If I am not in an admin setting.

Do I need to set up something for the distiller?

Doug
 
T

Tom Ogilvy

to me, that means Adobe PDF is not registered under that User ID (it isn't
in that user ID's registry entries).

You would need to use regsvr32.exe to register it.

If you put up broken code and say it works, then ask why it doesn't work
somewhere else, your not helping yourself.
 
D

douglascfast

Thought I would post a follow up for my issue.

It ends up the issue was my machine was trying to access
HKEY_CLASSES_ROOT\APPID

It wanted full access to the key (it did not write anything to the
Regestry)

So for those who end up with the error message of "Active X can't
create object"

You need full access to this key in order for the macro to work.
(Admins will have no issue)

Hope these helps some folks

Doug
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top