请教大家下面这段话转成VB。net为什么 gettype报错
以下是原来C#的代码
private void WordConvert()
{
Microsoft.Office.Interop.Word.ApplicationClass word = new Microsoft.Office.Interop.Word.ApplicationClass();
Type wordType = word.GetType();
Microsoft.Office.Interop.Word.Documents docs = word.Documents;
Type docsType = docs.GetType ();
object objDocName = @"c:\tmp\test.doc";
Microsoft.Office.Interop.Word.Document doc = (Microsoft.Office.Interop.Word.Document)docsType.InvokeMember("Open", System.Reflection.BindingFlags.InvokeMethod, null, docs, new Object[] { objDocName, true, true });
//打印输出到指定文件
Type docType = doc.GetType();
object printFileName = @"c:\tmp\test.ps";
docType.InvokeMember("PrintOut", System.Reflection.BindingFlags.InvokeMethod, null, doc, new object[] { false, false, Microsoft.Office.Interop.Word.WdPrintOutRange.wdPrintAllDocument, printFileName });
wordType.InvokeMember("Quit", System.Reflection.BindingFlags.InvokeMethod, null, word, null);
string o1 = "c:\\tmp\\test.ps";
string o2 = "c:\\tmp\\test.pdf";
string o3 = "";
//引用将PS转换成PDF的对象
try
{
ACRODISTXLib.PdfDistillerClass pdf = new ACRODISTXLib.PdfDistillerClass();
pdf.FileToPDF(o1, o2, o3);
}
catch { }
//为防止本方法调用多次时发生错误,必须停止acrodist.exe进程
foreach (System.Diagnostics.Process proc in System.Diagnostics.Process.GetProcesses())
{
int begpos;
int endpos;
string sProcName = proc.ToString();
begpos = sProcName.IndexOf("(") + 1;
endpos = sProcName.IndexOf(")");
sProcName = sProcName.Substring(begpos, endpos - begpos);
if (sProcName.ToLower().CompareTo("acrodist") == 0)
{
try
{
proc.Kill();
}
catch { }
break;
}
}
}
转成VB。NET
Private Sub WordConvert()
Dim word As Microsoft.Office.Interop.Word.ApplicationClass = New Microsoft.Office.Interop.Word.ApplicationClass()
Dim wordType As Type = word.GetType
Dim docs As Microsoft.Office.Interop.Word.Documents = word.Documents
Dim docsType As System.Type = docs.GetType() Dim objDocName As Object = "c:\tmp\test.doc"
Dim doc As Microsoft.Office.Interop.Word.Documents = DirectCast(docsType.InvokeMember("Open", System.Reflection.BindingFlags.InvokeMethod, Nothing, docs, New [Object]() {objDocName, True, True}), Microsoft.Office.Interop.Word.Documents)
'打印输出到指定文件
Dim docType As Type = doc.GetType Dim printFileName As Object = "c:\tmp\test.ps"
docType.InvokeMember("PrintOut", System.Reflection.BindingFlags.InvokeMethod, Nothing, doc, New Object() {False, False, Microsoft.Office.Interop.Word.WdPrintOutRange.wdPrintAllDocument, printFileName})
wordType.InvokeMember("Quit", System.Reflection.BindingFlags.InvokeMethod, Nothing, word, Nothing)
Dim o1 As String = "c:\tmp\test.ps"
Dim o2 As String = "c:\tmp\test.pdf"
Dim o3 As String = ""
'引用将PS转换成PDF的对象
Try
Dim pdf As New ACRODISTXLib.PdfDistillerClass()
pdf.FileToPDF(o1, o2, o3)
Catch
End Try
'为防止本方法调用多次时发生错误,必须停止acrodist.exe进程
For Each proc As Process In System.Diagnostics.Process.GetProcesses()
Dim begpos As Integer
Dim endpos As Integer
Dim sProcName As String = proc.ToString()
begpos = sProcName.IndexOf("(") + 1
endpos = sProcName.IndexOf(")")
sProcName = sProcName.Substring(begpos, endpos - begpos)
If sProcName.ToLower().CompareTo("acrodist") = 0 Then
Try
proc.Kill()
Catch
End Try
Exit For
End If
Next
End Sub
标成红色的2句话报错 ,请问如何解决