Hi Everyone,
I made a post a little while ago describing a situation I frequently found myself in and my desire for a robust solution. You can read it here if you like (https://community.alteryx.com/t5/Alteryx-Designer-Desktop-Discussions/How-to-move-untouched-Excel-Sh...), but the tl;dr is this:
Essentially, I needed a way to make exact copies of the excel sheets I was working with, formatting and all (really the crux of the whole issue), and transfer them into the output excel workbook that Alteryx is creating. The manual solution of just opening up the input and output files and copying the tabs over is not that bad, but for whatever reason I was determined to figure out a way to automate this part of the solution. In my example there are only two source workbooks, but in a situation with 5+ it could really save you some time once you get it set up.
You know what they say, if you can’t find someone to do the job, do it yourself. I have solved my own problem, and have attached the entirely self-contained solution macro below, and I’ll put some instructions/guidance further down in this post. The next few paragraphs will be me yapping about how it works if there’s any interest. Be warned that it involves running .ps1 and .bat files so you will see your command prompt come up when running it. Not sure how everyone’s IT department feels about this.
The yap:
The solution ended up being a PowerShell script that is created and updated dynamically by an Alteryx formula, and then converted to a blob and output as a .ps1 file. As part of that Alteryx formula you also dynamically create a .bat script that calls the powershell script. I'll be honest, I don't recall the exact reasoning why Alteryx couldn't run the powershell script directly, but it works, so I'm sticking with it. You actually end up having to do two .bats because I can't figure out how to get the Run Command Tool to point to a dynamic location either, and I wanted the titles for these scripts to be specific to the files they’re affecting. This minimizes the chance of any accidental error occurring. Let me describe the complete sequence below:
The Instructions/Guidance:
The Leftovers:
You might be thinking “wow, this was a lot of work for you to set this up, to accomplish very little”.
You are correct. But it’s done now.
Solved! Go to Solution.
@TheMattLeonard Thank you for posting. I like your solution because it showed me how you approached a very similar problem of mine. My problem was i needed to upload several hundred sheets to cloud based excel workbooks, reachable via hyperlink. I ended up using Visual Basic instead of Powershell, although Microsoft is planning to remove it in 2027. I approached this problem by using the report text tool instead of the formula tool because it is a much larger field for the script and i can keep it as one large text without 15 formula tools.
One good thing about vba, it creates a worksheet with a (1) after the name instead of overwriting if the same sheetname exists.
The issue with report text tool and powershell is that some of the syntax such as } curly braces get removed by the report text tool. If anyone has a solution to this problem please let me know.
@Richard_Data I appreciate the response! I'm glad there's at least one other user out there with a similar use case. I had no idea about VBA being discontinued, but that's honestly a bit of a relief as someone who never got around to learning it (and didn't use it for this project).
I had the option of appending (1) for new versions of the sheet instead of overwriting, but I chose the overwrite for my use case. I'll end up in situations where I'll be asked to generate a report in the morning, but then one of the source files will have an update that will require running the workflow again in the afternoon, and in those cases I just want to overwrite. I think any situation where I want to keep adding the new sheets I'll do a one off modification adding some kind of timestamp or another identifier.
I usually avoid the reporting tools like the plague since they can be tedious to setup when you're trying to use them to actually format an excel workpaper, but I can see how having the larger field helps.
In regards to your question about the curly bracket, I believe I have quite a few curly brackets in the scripts. Formula tool does not seem to have an issue with them. You're using single quotes (') instead of double quotes (") to surround your code, correct? I realize it might be a little different since the Report Text tool does not require everything to be in quotes to begin with.

