1. Paweł Kasperek
  2. PowerBuilder
  3. Friday, 22 September 2023 13:12 PM UTC


I have a problem with the performance of Word Application OLE Object  Application.FontNames collection after migration to PB 2022 R2. Follow is sample code:

OleObject iole_WORD

int li_retcode, li_count, k = 1

string ls_font


iole_WORD = CREATE OleObject
li_retcode = iole_WORD.ConnectToNewObject("word.application")
li_count = iole_WORD.Application.FontName.Count
For k=1 To li_count
  ls_font = iole_WORD.Application.FontNames.Item(k)

The function Application.FontNames.Item is very slow. I've ca. 120 fonts in my system installed. But my application compiled in PB 2021 works fine, with this performance problem. 



Accepted Answer
John Fauss Accepted Answer Pending Moderation
  1. Saturday, 23 September 2023 02:03 AM UTC
  2. PowerBuilder
  3. # Permalink

Hi, Pawel -

Application performance is affected by a lot of factors and a lot of the discussion involving performance is subjective... personal observations instead of measurements.

I took the code snippet you supplied, corrected the error "FontName.Count" instead of "FontNames.Count", and added some timing collection and reporting messageboxes, in five different PB versions/configurations. For each configuration, I ran the code four times and calculated the average elapsed time. Word reports that I have 180 fonts on my PC. All timings were made when running the code/app in the IDE.

PB 2017 R3 (32-bit): Average: 0.763 seconds
PB 2019 R3 (32-bit): Average: 0.657 seconds
PB 2021 (32-bit):      Average: 0.722 seconds
PB 2022 R2 (32-bit): Average: 0.690 seconds
PB 2022 R2 (64-bit): Average: 0.570 seconds

I see no evidence of "very slow" performance on my system. If you have other workstations you can test on, I suggest you do so, as there may be something unique to your PC.

If you or anyone else wants to measure the performance, I'm posting the code I used:

Integer   li_rc, li_count, li_index
Decimal   ldec_beg, ldec_end, ldec_elapsed
String    ls_fontname, ls_beg, ls_end
Time      lt_beg, lt_end
OleObject lole_word

lole_word = CREATE OleObject
If Not IsValid(lole_word) Then Return 0
li_rc = lole_word.ConnectToNewObject("Word.Application")
li_count = lole_word.Application.FontNames.Count

lt_beg = Now()
For li_index = 1 To li_count
   ls_fontname = lole_word.Application.FontNames.Item(li_index)
lt_end = Now()

ls_beg = String(lt_beg,'hh:mm:ss.fff')
ls_end = String(lt_end,'hh:mm:ss.fff')

ldec_beg = Dec(Mid(ls_beg,7))
ldec_end = Dec(Mid(ls_end,7))
If ldec_end < ldec_beg Then ldec_end += 60.0
ldec_elapsed = ldec_end - ldec_beg

MessageBox("PB 2017 R3","# of Fonts: ~t" + String(li_count) + &
   "~r~n~r~nEnd time: ~t" + ls_end + &
   "~r~nBegin time: ~t" + ls_beg + &
   "~r~n~t~t-----------------~r~nElapsed: ~t~t00:00:" + &

DESTROY lole_word

Return 0

Best regards, John

There are no comments made yet.
Angie Liu@Appeon Accepted Answer Pending Moderation
  1. Monday, 25 September 2023 05:16 AM UTC
  2. PowerBuilder
  3. # 1

Hi, Pawel;


I don't know if John's reply information is helpful to you.

We recommend that you try to find a clean environment to see if you can reproduce the problem. If you still have the problem in a clean environment, I suggest that you submit a ticket (at https://www.appeon.com/standardsupport/newbug) and provide your test case and information about your running environment, office version, and other relevant information so that we can reproduce and analyze the problem.




There are no comments made yet.
  • Page :
  • 1

There are no replies made for this question yet.
However, you are not allowed to reply to this question.