【发布时间】:2011-04-15 17:05:39
【问题描述】:
当您阅读本文时,虽然我在 C++ 和 Java 方面有相当不错的经验,但请记住,在 VB 方面我是一个完全的初学者。 :)
这是我想做的一个想法:
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
或者,如果我无法重新加载它,我可以执行以下操作:
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
我不太喜欢这样,因为它会导致窗口关闭/重新打开,并且我可能会丢失所有撤消历史记录。
有人可以在这里给我一些指导吗?
谢谢!
【问题讨论】:
标签: vb.net visual-studio visual-studio-2010 vba