# Is there something like pywin32 in Julia?

**URL:** https://discourse.julialang.org/t/is-there-something-like-pywin32-in-julia/37024
**Category:** General Usage
**Created:** [April 4, 2020, 4:54pm UTC](https://discourse.julialang.org/t/is-there-something-like-pywin32-in-julia/37024 "2020-04-04T16:54:03Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![feanor12](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/feanor12/32/8212_2.png) [@feanor12](https://discourse.julialang.org/u/feanor12)
#### Post date: [April 4, 2020, 4:54pm UTC](https://discourse.julialang.org/t/is-there-something-like-pywin32-in-julia/37024/1 "2020-04-04T16:54:03Z")

</div>

Is there something like pywin32 in Julia?  
I want to use the stmafm ole/com interface.

PyCall could work, but I am curious if there is a Julia native option.

---

<div class="post-metadata">

### Author: ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)
#### Post date: [April 4, 2020, 5:22pm UTC](https://discourse.julialang.org/t/is-there-something-like-pywin32-in-julia/37024/2 "2020-04-04T17:22:07Z")

</div>

You can already use `ccall` to natively access the Win32 API in Julia.

This is used extensively in the Julia standard library. See, for example, [how `tempname` is implemented for Windows](https://github.com/JuliaLang/julia/blob/c9805191e32fde9d4aa55e59493178f47444926e/base/file.jl#L498-L543).

Of course, if you are using Win32 APIs extensively, you might want higher-level wrappers on top of the Win32 API. AFAIK there has been no systematic effort to provide this — people usually just `ccall` at need. (One generally tries to keep such code to a minimum in most Julia packages, in order to keep things platform-independent.)

---

<div class="post-metadata">

### Author: ![ellocco](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ellocco/32/31331_2.png) [@ellocco](https://discourse.julialang.org/u/ellocco)
#### Post date: [April 8, 2022, 3:33pm UTC](https://discourse.julialang.org/t/is-there-something-like-pywin32-in-julia/37024/3 "2022-04-08T15:33:35Z")

</div>

Here is my example to use PyCall to open and modify an existing Excel-file via a COM server:

```julia
# Create COM server via Python Interface
# first: install "pywin32" via conda:
# using Conda; Conda.add("pywin32")

using PyCall
using XLSX
pw = pyimport("win32com")
pwc = pyimport("win32com.client")

FN_excel = raw"C:\tmp\MyTest.xlsx";
if ~isfile(FN_excel)
    XLSX.writetable(FN_excel)
end

xlApp = pwc.Dispatch("Excel.Application")
xlApp.Visible = 1
if isfile(FN_excel)
    workBook = xlApp.Workbooks.Open(FN_excel)
else
    error("file \"" * FN_excel * "\" does not exist!\n")
end
workBook.ActiveSheet.Cells(1, 1).Value = "hello world"
workBook.Close(SaveChanges = 1)
xlApp.Quit()

```

I hope it helps others to get started.
