Recently I updated my Visual Studio and start using the extention Macro Explorer.
I tried to use one of the sample macros "removes and sorts all", but I realized if I have a open documents, it doesn't run. So I closed all my open documents and try again this time it open all documents and close them but it doesn't work either.
The problem is the command executed before the document completely load. If there was a event or timer that can help wait until document load completely the problem will solve.
Here is my code. I marked where I want to add wait function:
function formatFile(file) {
dte.ExecuteCommand("View.SolutionExplorer");
if (file.Name.indexOf(".cs", file.Name.length - ".cs".length) !== -1) {
file.Open();
file.Document.Activate();
//here i want to wait for 1 second
dte.ExecuteCommand("Edit.RemoveAndSort");
file.Document.Save();
file.Document.Close();
}
}
I appreciate any sort of help.
Macro Explorer on GitHub: https://github.com/Microsoft/VS-Macros