Helpppp me with coddeeeeeee
Code:
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
this is the code to convert word documents to excel.
but i am getting error at underlines portion..the error is name not declared:(:( what should i do..I got thios code frm net and i just pasted it in visual studio..is there anybody to guide me to get my result??I am running short of tymm:(:(:(
Re: Helpppp me with coddeeeeeee
You need to add MS-Excel file references in you code.
Re: Helpppp me with coddeeeeeee
I have added Microsoft.office.Interop.excel as reference..is there anything else than this??
Re: Helpppp me with coddeeeeeee
Moved From The Codebank (which is for sharing code rather than posting questions :) )
Re: Helpppp me with coddeeeeeee
The only thing that comes to mind is to either Import the namespace... or use the fully qualified names ... here's the problem, the items marked in errors are constants or enums... they need to be defined before you can use them. they are defined in the Excel object model. I'm guessing by the look of the code, that it was actually designed to be run from an Excel macro within Excel... in which case all of those items would have been defined and in scope. You don't appear to be using them in Excel, so you need to get them defined (by adding the reference) and bring them in scope (by importing the namespace).
-tg
Re: Helpppp me with coddeeeeeee
like techgnome said import the namespace
vb Code:
Imports Excel = Microsoft.Office.Interop.Excel
and also activate the worksheet before pasting.
vb Code:
Dim xlWorkBook As Excel.Workbook
Dim xlWorkSheet As Excel.Worksheet
.
.
.
xlWorkSheet = xlWorkBook.Sheets("Sheet1")
xlWorkSheet.Activate()