PC Review


Reply
Thread Tools Rate Thread

assure that calculates ends before save to pdf starts

 
 
sverre
Guest
Posts: n/a
 
      16th Mar 2009
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 With Quote
 
 
 
 
OssieMac
Guest
Posts: n/a
 
      16th Mar 2009
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
>

 
Reply With Quote
 
ryguy7272
Guest
Posts: n/a
 
      16th Mar 2009
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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to get an event when a meeting starts and ends Jan K Microsoft Outlook VBA Programming 2 5th Nov 2008 10:43 PM
Changing when a day starts and ends Mark Microsoft Access Queries 2 6th Jul 2006 05:06 PM
Syncing files after DST starts or ends Gerald A. Connell Windows XP General 1 5th Apr 2005 04:39 AM
COMMAND.COM in XP starts then immediately ends John Windows XP General 9 13th Jun 2004 11:16 AM
XP no longer starts or ends properly tim stahlman Windows XP Basics 4 19th Jan 2004 04:00 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:46 PM.