VB代码,以将.doc转换为.xlsx ..纠正错误,请 [英] vb code to convery .doc to .xlsx..rectify errors please
问题描述
Option Explicit On
Imports System
Imports Microsoft.VisualBasic
Partial Public Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
End Sub
Sub GetDataFromWordDoc()
Dim sPath As String
Dim sFile As String
Dim MyWd As Object
sPath = "C:\ENGDATA\PDMS_Upload\Data_loading\BLOCK22\"
sFile = Dir(sPath & "*.doc")
Do While sFile <> ""
MyWd = GetObject(sPath & sFile)
MyWd.ActiveWindow.Selection.WholeStory()
MyWd.ActiveWindow.Selection.Copy()
Sheets("Sheet1").Cells.SpecialCells(xlCellTypeLastCell)
Offset(1, 1).End(xlToLeft).PasteSpecial(xlPasteValues)
sFile = Dir()
Loop
MyWd = Nothing
End Sub
End Class
我在工作表和iffset行中遇到错误.它说Sheets("
偏移量(1,1).结束( xlToLeft). PasteSpecial( xlPasteValues ),没有声明带下划线的单词
I am getting error in the sheets and iffset liness.. it says Sheets("Sheet1").Cells.SpecialCells(xlCellTypeLastCell)
Offset(1, 1).End(xlToLeft).PasteSpecial(xlPasteValues), underlined words aren't declared
推荐答案
您没有提供足够的信息,所以我将尝试猜测:
You don't provide enough information, so I'll try guessing:
首先,您似乎想为此使用Excel.但另一方面,.doc"应该与Word有关.那么,哪个是对的?
First, it looks like you want to use Excel for this purpose. But on the other side, ".doc" should be related to Word. So, which one is true?
Sheets不是独立的属性.它是工作簿对象的属性.您必须参考工作簿才能访问其Sheets属性.
Sheets is not a standalone property. It's the property of a Workbook object. You must refer to a Workbook to access it's Sheets property.
http://msdn.microsoft.com/en -us/library/microsoft.office.interop.excel._workbook.sheets.aspx
A workbook is a part of the Workbooks collection, which again is returned from an application object.
我建议去google或bing查找有关它的样本.
I suggest to google or bing to find samples about it.
这篇关于VB代码,以将.doc转换为.xlsx ..纠正错误,请的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!