Visio Makro Etkin diagram VBA kodlarını yönetin.

Bir VBA Modülü Ekleyin

Aşağıdaki örnek kod, yeni bir VBA Modülü ve Makro Kodu ekler ve çıktıyı VSDM biçiminde kaydeder. Bir kez, Microsoft Visio’de VSDM çıktı dosyasını açacaksınız veGeliştirici > Visual Basic menü komutları, “TestModule” adında bir modül göreceksiniz ve içinde aşağıdaki makro kodunu göreceksiniz.

 Sub ShowMessage()

    MsgBox "Welcome to Aspose!"

End Sub

İşte VSDM çıktı dosyasını VBA Modülü ve Makro Kodu ile oluşturmak için örnek kod.

// ExStart:ApplyThemeToNewShape
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Shapes();
// Load a diagram
Diagram diagram = new Diagram(dataDir + "1.vsdm");
//Add module
int index = diagram.VbaProject.Modules.Add(VbaModuleType.Procedural, "TestModule");
//Get module
Aspose.Diagram.Vba.VbaModule module = diagram.VbaProject.Modules[index];
//Set module
module.Codes = "Attribute VB_Name = \"module2\"\r\n Sub Button1_Click()\r\n\r\n MsgBox \"Welcome to Aspose!\"\r\n\r\nEnd Sub\r\n";
diagram.Save(dataDir + "1out.vsdm", SaveFileFormat.VSDM);

VBA veya Makroyu Değiştirin

Aşağıdaki örnek kod, içinde aşağıdaki VBA veya Makro kodu bulunan kaynak Visio dosyasını yükler.

 Sub Button1_Click()

    MsgBox "This is test message."

End Sub

Aspose.Diagram örnek kodunun yürütülmesinden sonra, VBA veya Makro kodu bu şekilde değiştirilecektir.

 Sub Button1_Click()

    MsgBox "This is Aspose.Diagram message."

End Sub

indirebilirsinizkaynak Visio dosyası veçıktı Visio dosyası verilen linklerden

// ExStart:ApplyThemeToNewShape
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_Shapes();
// Load a diagram
Diagram diagram = new Diagram(dataDir + "1.vsdm");
//Get module
Aspose.Diagram.Vba.VbaModule module = diagram.VbaProject.Modules[2];
//Set module
module.Codes = "Attribute VB_Name = \"module2\"\r\n Sub Button1_Click()\r\n\r\n MsgBox \"This is Aspose.Diagram message.\"\r\n\r\nEnd Sub\r\n";
diagram.Save(dataDir + "1out.vsdm", SaveFileFormat.VSDM);

ileri konular