Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I am having an issue where it takes almost a full minute for this code to finish creating a PDF. A publishing window comes up and it gets stuck after about 90% being complete. Then it waits there for what seems like a minute before it finishes. Not sure how to view in the code where it is stopping, but the code is pretty straight forward and I have used it on many other documents before. Here is what it looks like:
Sub OILPDF() Dim lastOILrow As Integer Dim message As Integer Dim Filename As Variant Dim lastPrintrow As Integer Dim viewdate As String viewdate = Format(Now(), "MM-DD-YYYY") Sheet11.Activate lastPrintrow = Sheet11.Cells(Sheet11.Rows.Count, 1).End(xlUp).Row Sheet11.Range(Cells(9, 1), Cells(lastPrintrow, 17)).ClearContents Sheet11.Range(Cells(9, 1), Cells(lastPrintrow, 17)).ClearFormats Sheet3.Activate lastOILrow = Sheet3.Cells(Sheet3.Rows.Count, 2).End(xlUp).Row Sheet3.Range(Cells(4, 1), Cells(lastOILrow, 17)).Copy Sheet11.Activate Sheet11.Cells(4, 1).PasteSpecial Filename = ActiveWorkbook.Path & Application.PathSeparator & Sheet11.Range("b6").Value & " Open Issues " & viewdate & ".pdf" Sheet11.ExportAsFixedFormat Type:=xlTypePDF, Filename:=Filename, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=True, OpenAfterPublish:=False Sheet3.Activate End Sub |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
This codes does the exact same thing. In the previous code, I am not sure which variable was named as a keyword.
Sub OILPDF() Application.ScreenUpdating = False 'Unprotect sheet so that work can be done Sheet3.Unprotect Password:="Tr2010" Sheet11.Unprotect Password:="Tr2010" Dim lrow As Integer Dim Fname As String Dim todaysDate As String todaysDate = Format(Now(), "MM-DD-YYYY") With Sheet11 lrow = .Cells(.Rows.Count, 1).End(xlUp).Row .Range(.Cells(9, 1), .Cells(lrow, 17)).ClearContents .Range(.Cells(9, 1), .Cells(lrow, 17)).ClearFormats End With With Sheet3 lrow = .Cells(Sheet3.Rows.Count, 2).End(xlUp).Row .Range(.Cells(4, 1), .Cells(lrow, 17)).Copy _ Sheet11.Cells(4, 1) End With Fname = ActiveWorkbook.Path & "\" & Sheet1.Range("C6").Value & " Open Issues " & todaysDate & ".pdf" Sheet11.ExportAsFixedFormat Type:=xlTypePDF, Filename:=Fname, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=True, OpenAfterPublish:=False 'Protect sheet so that no work can be done Sheet3.Protect Password:="Tr2010" Sheet11.Protect Password:="Tr2010" Application.ScreenUpdating = True End Sub |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
So I ended up getting it to work better. What I was initially doing was copying the information I wanted to print to another document and then using the Export to PDF function to print this document to PDF. I was doing this initially just so I didn't waste paper as I had 2000 lines called out in the document. Now what I am doing is just hiding everything past the last row and then printing and then unhiding. Its much quicker.
|
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Chris,
Am Mon, 15 Feb 2016 12:23:56 -0800 (PST) schrieb Chris Scott: So I ended up getting it to work better. What I was initially doing was copying the information I wanted to print to another document and then using the Export to PDF function to print this document to PDF. I was doing this initially just so I didn't waste paper as I had 2000 lines called out in the document. Now what I am doing is just hiding everything past the last row and then printing and then unhiding. Its much quicker. the code I posted runs in less than 1 second on my machine. Repair your Excel. Regards Claus B. -- Vista Ultimate / Windows7 Office 2007 Ultimate / 2010 Professional |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
What could be wrong with it and how would I go about repairing it?
|
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
There may be something of interest in a 5/18/2014 post titled "Excel to
PDF or XPS boilerplate routines". Also, check out Charlotte E's link for another excellent solution... -- Garry Free usenet access at http://www.eternal-september.org Classic VB Users Regroup! comp.lang.basic.visual.misc microsoft.public.vb.general.discussion |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Has Excel 2010 fixed slow down issues? | Excel Discussion (Misc queries) | |||
Entering data slow program down | New Users to Excel | |||
Slow Program | Excel Programming | |||
New computer with Vista caused Excel function slow down Issues | Excel Discussion (Misc queries) | |||
slow program in a loop | Excel Programming |