How to parse one variable to Microsoft Word

SparkOut SparkOutYNY at gmail.com
Sat Feb 21 06:22:47 EST 2009



Nhan, Tran Thi Thanh wrote:
> 
> 
> Hi all,
> 
>  Please help me with this issues: in my Run Rev application, when I click
> on button "Open file" will open file "template.doc" in Microsoft Word. How
> do I parse content of one field of card to this file?
> 
> Regards
> 
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
> 
> 
You could put the following VBScript into a custom property of your
application.
Before calling it, you can replace <<replacement text>> and the path to the
document if necessary.
Then do as vbscript. The "result" variable should be returned to Rev, so you
can see if there was any problem with opening the document.

Dim objWord, objDoc, objSelect, wdStory, result

on Error Resume Next
wdStory = 6
result = "OK"

Set objWord = CreateObject("Word.Application") 
If Err <> 0 Then 
  result = "Error opening Word application"
End If

If result = "OK" Then
  objWord.Visible = False
  With objWord
    Set objDoc = objWord.Documents.Open("<<path to document>>")
	If Err <> 0 Then
	  result = "Error opening template document"
	End If
  End With
End If

If result = "OK" Then
  Set objSelect = objWord.Selection
  objWord.Selection.HomeKey(wdStory)
  objSelect.Find.Forward = True
  objSelect.Find.Text = "{{replace me}}"
  objSelect.Find.Execute 
  If objSelect.Find.Found Then
    objSelect.Text = "<<replacement text>>"
  End If
  objWord.Selection.HomeKey(wdStory)
End If

If result = "OK" Then
  objWord.Visible = True
  Set objSelect= Nothing
  set objDoc = Nothing
  Set objWord = Nothing
Else
  set objDoc = Nothing
  objWord.Close
  objWord.Quit
End If







-- 
View this message in context: http://www.nabble.com/How-to-parse-one-variable-to-Microsoft-Word-tp22133088p22135096.html
Sent from the Revolution - User mailing list archive at Nabble.com.




More information about the use-livecode mailing list