ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Excel sheet to PDF Macro = security question (https://www.excelbanter.com/excel-programming/371245-excel-sheet-pdf-macro-%3D-security-question.html)

[email protected]

Excel sheet to PDF Macro = security question
 
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


Tom Ogilvy

Excel sheet to PDF Macro = security question
 
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?

--
Regards,
Tom Ogilvy



" wrote:

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



[email protected]

Excel sheet to PDF Macro = security question
 
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



Tom Ogilvy wrote:
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?

--
Regards,
Tom Ogilvy



" wrote:

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




Tom Ogilvy

Excel sheet to PDF Macro = security question
 
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.

--
Regards,
Tom Ogilvy




[email protected]

Excel sheet to PDF Macro = security question
 
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



All times are GMT +1. The time now is 11:48 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com