本文介绍了对象引用未设置为对象错误的实例。请指教。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面是我将对象引用设置为对象错误实例的行。请指教。

xlApp.ActiveWorkbook.XmlImport(Environment.CurrentDirectory +\ OHBS_U_Macro_Tracking.xml,ImportMap:= Nothing,Overwrite:= True,Destination:= xlRange1(A1))



我尝试过:



Dim xlApp As New Excel.Application

Dim txlWorkBook As Excel.Workbook

Dim xlWorkSheet As Excel.Worksheet

Dim xlRange1 As Excel.Range = Nothing

xlApp.Application.DisplayAlerts = False

xlApp.Application.CutCopyMode = False

xlApp.Application.ScreenUpdating = False



Dim i As Integer = 1

xlApp.DisplayAlerts = False

txlWorkBook = xlApp.Workbooks.Add



xlApp.Visible = True

xlWorkSheet = txlWorkBook.Sheets(Sheet1)



xlApp.ActiveWorkbook.XmlImport( Environment.CurrentDirectory +\\ \\ OHBS_U_Macro_Tracking.xml,ImportMap:= Nothing,Overwrite:= True,Destination:= xlRange1(A1))

Below is the line where I am getting Object reference not set to an instance of an object error. Please advise.
xlApp.ActiveWorkbook.XmlImport(Environment.CurrentDirectory + "\OHBS_U_Macro_Tracking.xml", ImportMap:=Nothing, Overwrite:=True, Destination:=xlRange1("A1"))

What I have tried:

Dim xlApp As New Excel.Application
Dim txlWorkBook As Excel.Workbook
Dim xlWorkSheet As Excel.Worksheet
Dim xlRange1 As Excel.Range = Nothing
xlApp.Application.DisplayAlerts = False
xlApp.Application.CutCopyMode = False
xlApp.Application.ScreenUpdating = False

Dim i As Integer = 1
xlApp.DisplayAlerts = False
txlWorkBook = xlApp.Workbooks.Add

xlApp.Visible = True
xlWorkSheet = txlWorkBook.Sheets("Sheet1")

xlApp.ActiveWorkbook.XmlImport(Environment.CurrentDirectory + "\OHBS_U_Macro_Tracking.xml", ImportMap:=Nothing, Overwrite:=True, Destination:=xlRange1("A1"))

推荐答案



这篇关于对象引用未设置为对象错误的实例。请指教。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 01:38