Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Excel vba printout method



I'm using excel 97 sr-2 on winnt 4.0

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Excel vba printout method

Previously posted by Jim Rech:

Jim Rech on writing a PDF

http://www.deja.com/getdoc.xp?AN=652844427&fmt=text

From: "Jim Rech"
Subject: Disable keyboard for SendKeys
Date: 31 Jul 2000 00:00:00 GMT
Message-ID: <#wktr0w#$GA.196@cppssbbsa04
References:


X-Priority: 3
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400
X-MSMail-Priority: Normal
Newsgroups: microsoft.public.excel.programming

What follows is a note I wrote some time ago on batch printing to a PDF
"printer". It's a lot better than sendkeys.

-------
The PDF driver looks for entries in an INI file and uses them for file names
automatically. If it doesn't find these entries then it prompts the user
for a file name. So your process would have to make these entries before
printing each workbook to the PDF "printer".

BTW, the INI file it looks for is "PDFWritr.ini" in the Windows\System
directory. So...

To write entries to INI files using the Windows API you need to have this
declarations at the top of your module:

Declare Function WritePrivateProfileStringA Lib "kernel32" _
(ByVal SectionStr As String, ByVal ItemName As String, _
ByVal Str2Write As String, ByVal IniFileName As String) As Boolean

Although you probably know the path to Windows\system, for portability it's
a good idea to have finding it be automatic. So include this API
declaration too:

Public Declare Function GetSystemDirectory Lib "kernel32" Alias _
"GetSystemDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As
Long

Include this module level variable to hold the path to the INI file:

Dim PDF_INIPath As String

Now before doing any printing run this to set things up:

Sub InitAutoPDF()
SetINIPath ''Set INI path/name variable
SetPDF_INI_Mode "Auto" ''Write entry to INI to put PDF driver in Auto
mode
End Sub

Now in your main file opening/printing macro your must set the name for the
PDF file to be created as each XLS is printed. This one uses the same name
as the source Excel file but with the extension PDF instead of XLS:

Sub MainPrintRoutine()
Dim WriteFile as String, FileLen as Integer
''Need a loop that opens each XLS and
'' puts its name in the variable WriteFile, and
'' the length of its file name in the variable FileLen
'' Then call this to set name in INI file
WritePDFFileName2Ini Left(WriteFile, FileLen - 3) & "pdf"
End Sub

When you're done run this sub to erase the last file name written to the INI
file and to put the PDF driver back in prompting mode:

Sub ResetManualPDF()
WritePDFFileName2Ini ""
SetPDF_INI_Mode "Prompt"
End Sub

And add these supporting subs called from above:

''Writes target PDF file name into INI
''This must be called prior to each printout
Sub WritePDFFileName2Ini(FName As String)
WritePrivateProfileStringA "Acrobat PDFWriter", "PDFFileName", FName,
PDF_INIPath
End Sub

''Set "CreatePDFExcelMacroShowDialog" entry in INI to passed setting
''The settings are "Prompt" and "Auto"
Sub SetPDF_INI_Mode(Setting As String)
WritePrivateProfileStringA "Acrobat PDFWriter",
"CreatePDFExcelMacroShowDialog", Setting, PDF_INIPath
End Sub

''Sets variable pointing to PDF INI file
Function SetINIPath() As Boolean
Dim Buff As String * 100
Dim RetVal As Long
RetVal = GetSystemDirectory(Buff, 100)
If RetVal 0 Then
PDF_INIPath = Left(Buff, RetVal) & "\PDFWritr.ini"
SetINIPath = True
Else
MsgBox "Cannot find the Windows System Directory"
End If
End Function

BTW, I extracted all this from a working module but changed some things
around for clarity. So I may have mis-typed some things but hopefully you
can fix these things up.

--
Jim Rech
Excel MVP

--
Regards,
Tom Ogilvy

"Curtis Marchand" wrote in message
...


I'm using excel 97 sr-2 on winnt 4.0

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Excel vba printout method

You forgot that i'm using winnt 4.0 not windows 95/98
There is no directory windows/system
There is winnt/system
/system32
an there is no ini file PDFWritr.ini in winnt
I searched every local drive.

I would like to apply your theory in win nt if it is possible.

Regards
Curtis

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Excel vba printout method

PDFwritr
PDFwriter
Create PDF

I understand Windows 2000 uses the registry - can't say for Window NT 4.0.

You can download the Acrobat SDK for version 5 here.

http://partners.adobe.com/asn/acrobat/download.jsp

it is at the bottom - the verions 6 full install requires being an ASN
member (whatever that is). Anyway, the registry approach is supposed to be
documented in the SDK. I would assume it will clarify what NT 4.0 needs as
well.

--
Regards,
Tom Ogilvy






"Curtis Marchand" wrote in message
...
You forgot that i'm using winnt 4.0 not windows 95/98
There is no directory windows/system
There is winnt/system
/system32
an there is no ini file PDFWritr.ini in winnt
I searched every local drive.

I would like to apply your theory in win nt if it is possible.

Regards
Curtis

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Excel vba printout method

Looks like you have to register for the ASN thing anyway - but it doesn't
cost anything.

--
Regards,
Tom Ogilvy

"Tom Ogilvy" wrote in message
...
PDFwritr
PDFwriter
Create PDF

I understand Windows 2000 uses the registry - can't say for Window NT 4.0.

You can download the Acrobat SDK for version 5 here.

http://partners.adobe.com/asn/acrobat/download.jsp

it is at the bottom - the verions 6 full install requires being an ASN
member (whatever that is). Anyway, the registry approach is supposed to

be
documented in the SDK. I would assume it will clarify what NT 4.0 needs

as
well.

--
Regards,
Tom Ogilvy






"Curtis Marchand" wrote in message
...
You forgot that i'm using winnt 4.0 not windows 95/98
There is no directory windows/system
There is winnt/system
/system32
an there is no ini file PDFWritr.ini in winnt
I searched every local drive.

I would like to apply your theory in win nt if it is possible.

Regards
Curtis

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!







Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel Printout becky57 New Users to Excel 3 February 4th 09 01:42 AM
Printout looks different than screen - Excel 2007 Celeste[_2_] Excel Discussion (Misc queries) 1 September 9th 08 12:41 AM
Please post this thread a correct full method, method about Nast Runsome New Users to Excel 8 February 25th 08 03:29 PM
Please post this thread a complete correct method, method about te Nast Runsome New Users to Excel 0 February 23rd 08 09:42 PM
my excel printout not straight helenakwek Excel Worksheet Functions 1 October 20th 06 01:50 PM


All times are GMT +1. The time now is 01:29 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"