Is it possible to run VBA code in VB (.NET)? If so, what is needed to do so? For example, if I wanted to create a new document in Word, I would use:
VB Code:
Dim MyDoc As Word.Document Documents.Add.SaveAs("Hello.doc") Set MyDoc = Documents("Hello.doc")
Trying to paste it into VB.NET:
VB Code:
Public Class Form1 Inherits System.Windows.Forms.Form [b]Windows Form Designer Generated Code[/b] Private Sub Button1_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles Button1.Click Dim MyDoc As Word.Document Documents.Add.SaveAs("Hello.doc") MyDoc = Documents("Hello.doc") End Sub End Class
I get errors such as "Type 'Word.Document' is not defined" and "Name 'Documents' is not declared."
What needs to be done in order to get this working (if it's possible)? I only started coding in VB a few weeks ago so bear with me if this is an inane question. I've been searching all over google and any VB forum I could find for the answer to this question but haven't found anything.




Reply With Quote