How to save @macroexpand output to file on windows?

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?

@macroexpand returns an expression so you can do it like

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