Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 78
Default assure that calculates ends before save to pdf starts

Hi, I have written below little procedure. I noticed that when I have a lot
of data to be recalculated the save-command starts before the calculate has
finished making my pdf-files incorrect. Is there any line I can add to solve
this?

By the way - automatic calc is turned off the the workbook.

Many thanks in advance,
Sverre

Sub PrintAllPortfoliosToFile()
'
' PrintAllPortfoliosToFile Macro
'
'Ändra namn på filen (och katalogen)

Dim portfolio As String
'
For Row = 2 To 21
portfolio = CStr(Cells(Row, 17))
Cells(2, 2) = portfolio
Calculate
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:="C:\Documents and
Settings\sverker\Desktop\Analys och uppföljning\PDF-rapporter\Uppföljning
20090228_" + portfolio + ".pdf" _
, Quality:=xlQualityStandard, IncludeDocProperties:=True,
IgnorePrintAreas:=False, OpenAfterPublish:=False
Next Row

'
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default assure that calculates ends before save to pdf starts

Untested but 2 things to try.

OnTime method. Check it out in Help. (Try this one first)

Wait method. Also check out in Help for what it does.

I suggest that you place the printing code in a sub of its own and try the
above after the Calculate code to try to force the system to stall for
whatever number of seconds you think it takes for the Calculate to finish and
then on the next line Call the printing sub.

i will be interested to know if it works.
--
Regards,

OssieMac


"sverre" wrote:

Hi, I have written below little procedure. I noticed that when I have a lot
of data to be recalculated the save-command starts before the calculate has
finished making my pdf-files incorrect. Is there any line I can add to solve
this?

By the way - automatic calc is turned off the the workbook.

Many thanks in advance,
Sverre

Sub PrintAllPortfoliosToFile()
'
' PrintAllPortfoliosToFile Macro
'
'Ändra namn på filen (och katalogen)

Dim portfolio As String
'
For Row = 2 To 21
portfolio = CStr(Cells(Row, 17))
Cells(2, 2) = portfolio
Calculate
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:="C:\Documents and
Settings\sverker\Desktop\Analys och uppföljning\PDF-rapporter\Uppföljning
20090228_" + portfolio + ".pdf" _
, Quality:=xlQualityStandard, IncludeDocProperties:=True,
IgnorePrintAreas:=False, OpenAfterPublish:=False
Next Row

'
End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,836
Default assure that calculates ends before save to pdf starts

I'm not exactly sure how to guarantee that Excel finishes the calculation
before saving, but you can pause the Macro before the code sequence
continues.

Try something like this:
Application.Wait Now + TimeValue("00:00:10")

Also, shouldn't those "+" symbols be "&" symbols?


--
RyGuy


"sverre" wrote:

Hi, I have written below little procedure. I noticed that when I have a lot
of data to be recalculated the save-command starts before the calculate has
finished making my pdf-files incorrect. Is there any line I can add to solve
this?

By the way - automatic calc is turned off the the workbook.

Many thanks in advance,
Sverre

Sub PrintAllPortfoliosToFile()
'
' PrintAllPortfoliosToFile Macro
'
'Ändra namn på filen (och katalogen)

Dim portfolio As String
'
For Row = 2 To 21
portfolio = CStr(Cells(Row, 17))
Cells(2, 2) = portfolio
Calculate
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:="C:\Documents and
Settings\sverker\Desktop\Analys och uppföljning\PDF-rapporter\Uppföljning
20090228_" + portfolio + ".pdf" _
, Quality:=xlQualityStandard, IncludeDocProperties:=True,
IgnorePrintAreas:=False, OpenAfterPublish:=False
Next Row

'
End Sub

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 E-2007 starts, but Installer also starts 3 times??? Thanks for the Great Tip Setting up and Configuration of Excel 0 January 24th 10 03:21 AM
filter using "ends with" and 3 choices? Ex: ends with 1,2 or3 Debbie Excel Worksheet Functions 1 April 6th 07 12:07 AM
Assure entry is numeric merritts[_5_] Excel Programming 1 June 28th 06 07:38 PM
If function that calculates Ernie [email protected] Excel Worksheet Functions 6 April 28th 05 07:32 PM
How do i assure a pull down list begins at the top of the range? BCW Excel Programming 2 December 15th 04 04:23 AM


All times are GMT +1. The time now is 04:07 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"