views:

24

answers:

1

As you read this, though I have pretty good experience in C++ and Java, please keep in mind that I am a complete beginner when it comes to VB. :)

Here is one idea of what I want to do:

Option Strict Off
Option Explicit Off
Imports System
Imports EnvDTE
Imports EnvDTE80
Imports EnvDTE90
Imports EnvDTE90a
Imports EnvDTE100
Imports System.Diagnostics

Public Module RecordingModule


    Sub TemporaryMacro()
// what is the right way to declare and define filename?
        dim String filename = DTE.ActiveDocument.FullName();
        DTE.ActiveDocument.Save()
// how do I make a system call, I'm pretty sure this is not correct
        System("astyle.exe " + filename);
// reload the formatted file, but how?
    End Sub
End Module

Alternatively, if I cannot reload it, I could do something like:

Option Strict Off
Option Explicit Off
Imports System
Imports EnvDTE
Imports EnvDTE80
Imports EnvDTE90
Imports EnvDTE90a
Imports EnvDTE100
Imports System.Diagnostics

Public Module RecordingModule


    Sub TemporaryMacro()
// what is the right way to declare and define filename?
        dim String filename = DTE.ActiveDocument.FullName();
        DTE.ActiveDocument.Save()
        DTE.ActiveDocument.Close()
// how do I make a system call, I'm pretty sure this is not correct
        System("astyle.exe " + filename);
        DTE.ExecuteCommand("File.Open",filename);
    End Sub
End Module

I don't much like that though as it will cause the windows to close/reopen and I will probably loose all of my undo history.

Can anyone give me some guidance here?

Thanks!

+1  A: 

A system call can be done with System.Diagnostics.Process.Start("executable.exe", "args") If the modified Document is currently open visual studio will ask you if you want to reload it. If you close if before the operation you can reload it with DTE.ItemOperations.OpenFile("filename")

Noffls
Thanks, this got me exactly to where I wanted to be:
Mark