You need to be logged in to view a user's profile.
  1. william yau
  2. PowerBuilder
  3. Thursday, 7 November 2024 09:09 AM UTC

Dear Guru,

I have a question. I have an application built with PowerBuilder 7.0 that contains a script similar to the one below. There is a function that opens, edits, and saves a document as a PDF. This function was working fine before, but last week, on some desktops, when running this function, the text can be converted to PDF, but the pictures in Word documents are not being correctly converted to PDF.

ls_wscript = 'Dim objDoc, objWord' // Declare variables
ls_wscript = ls_wscript + '~r~n' + 'Set objWord = CreateObject( "Word.Application" )' // Create a Word object
ls_wscript = ls_wscript + '~r~n' + 'With objWord'
ls_wscript = ls_wscript + '~r~n' + '.Visible = True' // True: make Word visible; False: invisible
ls_wscript = ls_wscript + '~r~n' + '.WindowState = 2' // True: make Word visible; False: invisible
ls_wscript = ls_wscript + '~r~n' + '.Documents.Open "' + ls_doc_path + '"' // Open the Word document
ls_wscript = ls_wscript + '~r~n' + 'Set objDoc = .ActiveDocument' // Make the opened file the active document
ls_wscript = ls_wscript + '~r~n' + 'objDoc.SaveAs "' + ls_photo_path + '", 17' // ' Save as pdf, file format of pdf = 17
ls_wscript = ls_wscript + '~r~n' + 'objDoc.Close' // Close the active document
ls_wscript = ls_wscript + '~r~n' + '.Quit' // Close Word
ls_wscript = ls_wscript + '~r~n' + 'End With'

 

li_FileNum = FileOpen(ls_wscript_path, StreamMode!, Write!, LockReadWrite!, Replace!)
filewrite(li_FileNum, ls_wscript)
fileclose(li_FileNum)

// run Wscript
li_rc = wsh.Run('wscript.exe "' + ls_wscript_path + '"' , MINIMIZED, WAIT)

 

Please help me and give advice

 

William

 

 

 

 

René Ullrich Accepted Answer Pending Moderation
  1. Friday, 8 November 2024 05:31 AM UTC
  2. PowerBuilder
  3. # 1

I don't have a example with Word but I think you can replace your code in this way: (not tested)

OLEObject lole_word, lole_doc

lole_word = CREATE oleobject
lole_word.ConnectToNewObject ("Word.Application")

lole_word.Visible = True
lole_word.WindowState = 2
lole_word.Documents.Open (ls_doc_path)
lole_doc = lole_word.ActiveDocument
lole_doc.SaveAs (ls_photo_path, 17)
lole_doc.Close ()
lole_word.Quit ()

lole_word.Disconnectobject ()
DESTROY lole_word

Comment
  1. Armeen Mazda @Appeon
  2. Saturday, 9 November 2024 01:33 AM UTC
Thanks Rene for your great help!
  1. Helpful
There are no comments made yet.
william yau Accepted Answer Pending Moderation
  1. Friday, 8 November 2024 00:48 AM UTC
  2. PowerBuilder
  3. # 2

Rene Ullrich 

 

Thank you for your quick and helpful response. Could you please provide me with an example for reference on creating an OLE method

 

best regards

 

William 

 

 

 

 

 

 

 

 

 

 

 

 

Comment
There are no comments made yet.
René Ullrich Accepted Answer Pending Moderation
  1. Thursday, 7 November 2024 10:21 AM UTC
  2. PowerBuilder
  3. # 3

I think this is a Word problem and not a PowerBuilder problem. You should ask this in a forum with Word experts.

 

BTW: You could also access word directly from PB using OLE instead of create and run a script. I think it should also work with PB 7. 

Comment
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.