# How to save @macroexpand output to file on windows?

**URL:** <https://discourse.julialang.org/t/how-to-save-macroexpand-output-to-file-on-windows/116452>\
**Category:** General Usage\
**Tags:** macros\
**Created:** [July 1, 2024, 1:27am UTC](https://discourse.julialang.org/t/how-to-save-macroexpand-output-to-file-on-windows/116452 "2024-07-01T01:27:34Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![freedomjin](https://avatars.discourse-cdn.com/v4/letter/f/f4b2a3/32.png) [@freedomjin](https://discourse.julialang.org/u/freedomjin)\
**Post date:** [July 1, 2024, 1:27am UTC](https://discourse.julialang.org/t/how-to-save-macroexpand-output-to-file-on-windows/116452/1 "2024-07-01T01:27:34Z")

</div>

Hi, I’m studying someone else’s macro code, and would like to save the generated code to a file using @macroexpand and check out what is been done. But @macroexpand does not seem to return a string or any object, it only prints to the REPL. I tried `@macroexpand @mymacro > "mycode.jl"` on windows, but it does not seem to work. What is a simple n quick way to do this, other than copy n paste by hand?

---

<div class="post-metadata">

**Author:** ![MilesCranmer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/milescranmer/32/21070_2.png) [@MilesCranmer](https://discourse.julialang.org/u/MilesCranmer)\
**Post date:** [July 1, 2024, 1:55am UTC](https://discourse.julialang.org/t/how-to-save-macroexpand-output-to-file-on-windows/116452/2 "2024-07-01T01:55:04Z")

</div>

`@macroexpand` returns an expression so you can do it like

```julia
julia> open("mycode.jl", "w") do io
           m = @macroexpand(@inline x = 1)
           write(io, string(m))
       end

```
