Open Bouki6 opened 7 years ago
Thanks for identifying the issue. The samples can be edited directly in Visual Studio. You absolutely can add a timer to ensure that the page has loaded completely. If you get it working, feel free to submit a PR and we'll consider pulling it into the source for all users.
I would recommend putting a timer somewhere after the file.Document.Activate() command in the formatFile method. Here: https://github.com/Microsoft/VS-Macros/blob/master/VSMacros/Macros/Samples/Documents/Remove%20and%20Sort%20All.js#L33
Hope that helps.
Hello. thank you for responding to my problem so fast. unfortunately i couldn't manage to solve it by timer. but i use a loop in order to wait for appropriate time. also i added a new line in order to CollapsetoDefinitions. here is my code:
function formatFile(file) {
dte.ExecuteCommand("View.SolutionExplorer");
if (file.Name.indexOf(".cs", file.Name.length - ".cs".length) !== -1) {
file.Open();
file.Document.Activate();
for (var i = 1; i <= 4000; i++) {
file.Document.Activate();
}
dte.ExecuteCommand("Edit.RemoveAndSort");
dte.ExecuteCommand("Edit.CollapsetoDefinitions");
file.Document.Save();
file.Document.Close();
}
}
i appreciate any sort of help.
thank you.
Hello. recently i updated my visual studio and start using 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 ether. the problem is command execute before the document completely load. if there was a event or timer that can help wait until document load completely the problem will solve. i appreciate any sort of help. thank you.