Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

PDFcreator: Create PDF from protected XLS file (used to work)

28 views
Skip to first unread message

J...@noreply.nl

unread,
Jan 28, 2015, 11:02:16 AM1/28/15
to
In the past I used following script to make a PDF from a sheet in a
protected excel file.

--------------------------------------------------------------------------------
set vbs=%temp%\ExcelPrint.vbs
:: Build VBScript file
findstr "'%skip%VBS" "%~f0" > "%vbs%"

::set /p Pass=Enter Password to edit excel file:
set pass=nottherealpassw

cscript //nologo "%vbs%" "D:\M\Desktop\myfile.xls" "mysheet"
"C:\Program Files\PDFCreator\PDFCreator.exe" 1 %Pass%
:: Open File.xls with "YourPassword" and print 1 copy of Sheet named Chart
:: to PDFCreator printer driver.

Del %vbs%
goto :eof

'Create this VBScript on the fly 'VBS
Set ObjArgs = wscript.arguments 'VBS
strFileName = objargs(0) 'VBS
strWorkSheetName = objargs(1) 'VBS
strPrinter = objargs(2) 'VBS
intCopies = objargs(3) 'VBS
strPassword = objargs(4) 'VBS
Set XLApp= CreateObject("Excel.Application") 'VBS
XLApp.Visible = False 'VBS
Set XLWkbk = XLApp.Workbooks.Open(strFileName,,,,,strPassword) 'VBS

XLWkbk.sheets(strWorkSheetName).PrintOut , , intCopies, , strPrinter
'VBS
XLWkbk.Close False 'VBS
XLApp.Quit 'VBS
Set XLWkbk = Nothing 'VBS
Set XLApp = Nothing 'VBS
Set ObjArgs = Nothing 'VBS
--------------------------------------------------------------------------------

This worked well.
Now, with a newer version of PDFcreator and a new computer with
Windows7. I can't get it to work.

I don't know what I do wrong.
The newest version of PDFcreator has a built in FTP feature that I can
use to upload the created PDF file to the server I want so this would
cover all my problems.

Anyone an idea?
I really don't know what profile settings I have to use for PDFcreator
to get this working..

:(

--- news://freenews.netfront.net/ - complaints: ne...@netfront.net ---

foxidrive

unread,
Jan 28, 2015, 11:13:59 AM1/28/15
to
On 29/01/2015 03:02, J...@noreply.nl wrote:
> This worked well.
> Now, with a newer version of PDFcreator and a new computer with
> Windows7. I can't get it to work.

Did you use XP earlier?

Try elevating permissions for the file - but the current folder will be the c:\windows\system32
folder so you may need to change directory first.


J...@noreply.nl

unread,
Jan 28, 2015, 12:47:44 PM1/28/15
to
Yes I did use XP before.

The file which I try to open has now all permissions for all users.
What do you mean with current folder?
The folder where which PDFcreator is installed?

The PDFcreator is stored in the path: C:\Program
Files\PDFCreator\PDFCreator.exe
It still doesn't work with the elevated rights

Thank you for your quick response.

foxidrive

unread,
Jan 28, 2015, 8:53:47 PM1/28/15
to
On 29/01/2015 04:47, J...@noreply.nl wrote:
> Yes I did use XP before.

Windows implements additional security in Vista and later.

> The file which I try to open has now all permissions for all users.

What I mean is right click on the batch file and select "Run as Administrator" or similar.

> What do you mean with current folder?
> The folder where which PDFcreator is installed?

The batch file usually uses the directory it is stored in as the working folder,
however when you run-as-admin the working folder is changed to c:\windows\system32.

So if your code relies on the directory it is stored in, then you'll need a line
at the top that says this:

cd /d "%~dp0"


If it works then you may be able to change the properties of the icon to run as administrator
or use runas.exe to script it.


J...@noreply.nl

unread,
Jan 30, 2015, 10:59:17 AM1/30/15
to
Hey Thank you!

But unfortunately this also doesn't work.
The problem isn't printing the file to PDF but to open the file for
printing..
The XLS file has a password to edit the file and there should be a
pointer for PDFcreator to open the right worksheet.

This used to work with XP, now this doesn't seem to work with W7...
Even if I elevate the way the batch runs, it doesn't work..

Maybe I better look for another way to get this done.
:-(

Win7 with it's stupid user rights :-(
0 new messages