LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Excel to PDF


Below is a modified code from a recorded macro whose purpose is to print
to a pdfdriver and then save. Manually this takes a long time when the
user deals with more than a handful cells. In my case, my range
consists of 200+ cells. Everything seems correct with one exception --
the file is created but no data is saved. That is to say that when I
open "My Documents" I see a properly named PDF file but of size 0KB
(should be roughly 4.5 KB). When I attempt to open it, I receive a
file read error. I am wondering if there is anything wrong with the
code or if it's a problem with my writer. I am hesitant to say that it
is the writer because if I do each file manually, they are created and
viewed without error. Thank you all who reply.



Code:
--------------------
Sub PrintToPDF()
'
'
Dim Products As Range
Dim Filename As String

Set Products = Worksheets("Summary").Range("Products")

For Each cell In Products
If IsEmpty(cell) Then Exit For

Filename = cell
cell.Copy

Worksheets("Historical").Paste Destination:=Worksheets("Historical").Cells(2, 1)

Application.CutCopyMode = False
Application.Calculate

Application.ActivePrinter = "Acrobat PDFWriter on LPT1:"
ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
"Acrobat PDFWriter on LPT1:", PrintToFile:=True, PrToFileName:="C:\My Documents\" & Filename & ".pdf"

Next cell
End Sub

--------------------


-- Isaac


--
I Maycotte
------------------------------------------------------------------------
I Maycotte's Profile: http://www.excelforum.com/member.php...o&userid=35604
View this thread: http://www.excelforum.com/showthread...hreadid=562549

 
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



All times are GMT +1. The time now is 07:26 AM.

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"