I am working on converting a powershell script to Racket that takes a Word 
XML document and saves it as PDF.

In powershell, when I call Word's `Documents.Open` method I can just pass 
it the naked string as the file path without anything special done to it. 
In Racket, however, when I run the following code I get an error telling me 
the type is bad

```
  (define xml-document (string-append (path->string (path->complete-path 
(build-path (find-system-path 'orig-dir)  "temp"))) "\\" tag ".xml"))
  (define pdf-document (string-append (path->string (simplify-path 
(path->complete-path (build-path 'up "formatted")) #t)) "\\" tag ".pdf"))
  (define word-instance (com-create-instance "Word.Application"))
  (define word-document (com-invoke (com-get-property word-instance 
"Documents") "Open" xml-document))
  (com-invoke book "ExportAsFixedFormat"
      pdf-document 
      17 com-omit com-omit com-omit com-omit com-omit com-omit com-omit 
com-omit 
      1)
  (com-invoke book "Close")
  (com-invoke word-instance "Quit")
  (com-release word-instance)

```
This gives the following error on the line the **define word-document** 

> Open: expected argument of type <(opt (box any))>; given:
> "...\\pdf_gen\\temp\\filename.xml"


I am very confused by this as the documentation suggests that I should be 
able to plug in the path as a string, the error suggests otherwise?

I've tried both the regular and CS versions of Racket 7.4

Relevant Racket and Word documentation:

[Racket COM 
Documentation](https://docs.racket-lang.org/foreign/com-auto.html?q=com)

[MS Word COM Open 
Method](https://docs.microsoft.com/en-us/dotnet/api/microsoft.office.interop.word.documents.open?view=word-pia#parameters)

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/423334b3-607e-4041-b046-06528c0ea5d7%40googlegroups.com.

Reply via email to