|
Hello all
I'm trying to include the a Grammer check into my app; one of the approaches that I've come across is using MS.Words' but it seem that I'm facing somedefficulties that I can't figure out;
mports System.Runtime.InteropServices
Public Class Form1
Inherits System.Windows.Forms.Form
' Invokes either the spell or grammar checker.
Private Sub SpellOrGrammarCheck(ByVal blnSpellOnly As Boolean)
Try
' Create Word and temporary document objects.
Dim objWord As Object
Dim objTempDoc As Object
' Declare an IDataObject to hold the data returned from the
' clipboard.
Dim iData As IDataObject
' If there is no data to spell check, then exit sub here.
If TextBox1.Text = "" Then
Exit Sub
End If
objWord = New Word.Application() // My problem is here as it shows that it is not defined
objTempDoc = objWord.Documents.Add
objWord.Visible = False
' Position Word off the screen...this keeps Word invisible
' throughout.
objWord.WindowState = 0
objWord.Top = -3000
' Copy the contents of the textbox to the clipboard
Clipboard.SetDataObject(TextBox1.Text)
' With the temporary document, perform either a spell check or a
' complete
' grammar check, based on user selection.
With objTempDoc
.Content.Paste()
.Activate()
If blnSpellOnly Then
.CheckSpelling()
Else
.CheckGrammar()
End If
' After user has made changes, use the clipboard to
' transfer the contents back to the text box
.Content.Copy()
iData = Clipboard.GetDataObject
If iData.GetDataPresent(DataFormats.Text) Then
TextBox1.Text = CType(iData.GetData(DataFormats.Text), _
String)
End If
.Saved = True
.Close()
End With
objWord.Quit()
MessageBox.Show("The spelling check is complete.", _
"Spell Checker", MessageBoxButtons.OK, _
MessageBoxIcon.Information)
' Microsoft Word must be installed.
Catch COMExcep As COMException
MessageBox.Show( _
"Microsoft Word must be installed for Spell/Grammar Check " _
& "to run.", "Spell Checker")
Catch Excep As Exception
MessageBox.Show("An error has occured.", "Spell Checker")
End Try
End Sub
Private Sub btnSpellCheck_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnSpellCheck.Click
SpellOrGrammarCheck(True)
End Sub
Private Sub btnGrammarCheck_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnGrammarCheck.Click
SpellOrGrammarCheck(False)
End Sub
End Class
>
any help? I've added the reference Microsoft Word 12.0 object but still has the same problem undefined ..!!!?
or if any has another idea; I will highly appreciate it...
cheers
|
|
|
|
|
Are you getting any error message?
I guess you need to use fully qualified names.
जय हिंद
|
|
|
|
|
Yes it is an error message ...
|
|
|
|
|
You need to specify the fully qualified name as I had mentioned before ie use
Microsoft.Office.Interop.Word.Application .
जय हिंद
|
|
|
|
|
I've done what you have mentioned; I appreciate your help...and now it says on the error message "Error Expected" what does it mean?
|
|
|
|
|
Hi All,
I want to work with some fonts which are created by me. But i don't want to install those in system Font folder.Which are accessed by only my software.
Pls help.How can it Possible.
Thanks
mailto: anubhava.prodata@gmail.com
|
|
|
|
|
|
Very cool, didn't know that existed.
Any suggestions, ideas, or 'constructive criticism' are always welcome.
"There's no such thing as a stupid question, only stupid people." - Mr. Garrison
|
|
|
|
|
When I start my program, it gives me error on this line.
.SubItems.Add(MyDataReader("A2".ToString))
"Overload resolution failed because no Public "add" can be called with these arguments"
Don't know what hte problem is........
Here are the code
Public Function FillListBox(ByVal Sqlstring As String)
ListBox1.Items.Clear()
ListView1.Items.Clear()
Dim OleDbConn As OleDbConnection = New OleDbConnection(ConnString)
OleDbConn.Open()
Dim MyDataReader As OleDbDataReader
Dim MyOleDbCommand As OleDbCommand = New OleDbCommand()
Dim MyDataSet As DataSet = New DataSet()
Dim MyOleDataAdapter As OleDbDataAdapter = New OleDbDataAdapter()
MyOleDataAdapter.SelectCommand = New OleDbCommand(Sqlstring, OleDbConn)
MyOleDataAdapter.Fill(MyDataSet)
MyOleDbCommand.Connection = (OleDbConn)
MyOleDbCommand.CommandText = Sqlstring
MyDataReader = MyOleDbCommand.ExecuteReader
Do While MyDataReader.Read
ListBox1.Items.Add(MyDataReader("Luidraad"))
Dim MyItem = ListView1.Items.Add(MyDataReader("luidraad".ToString))
With MyItem
.SubItems.Add(MyDataReader("A1".ToString))
.SubItems.Add(MyDataReader("A2".ToString))
.SubItems.Add(MyDataReader("A2".ToString))
.SubItems.Add(MyDataReader("A3".ToString))
.SubItems.Add(MyDataReader("A4".ToString))
.SubItems.Add(MyDataReader("A5".ToString))
.SubItems.Add(MyDataReader("A6".ToString))
.SubItems.Add(MyDataReader("A7".ToString))
.SubItems.Add(MyDataReader("A8".ToString))
.SubItems.Add(MyDataReader("A9".ToString))
.SubItems.Add(MyDataReader("A10".ToString))
End With
Loop
MyDataReader.Close()
OleDbConn.Close()
OleDbConn.Dispose()
|
|
|
|
|
.SubItems.Add(MyDataReader("A2".ToString())
BTW, "A2" is already a string?
I are troll
|
|
|
|
|
Eddy Vluggen wrote: "A2" is already a string?
it is a short string.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
I had hoped never to be reminded of the shortstring again, along with the existence of the AnsiString, the PChar, the..
I are troll
|
|
|
|
|
Perhaps:
.SubItems.Add(MyDataReader("A2").ToString)
?
|
|
|
|
|
Thank you it works
|
|
|
|
|
Hi,
In my application I am trying to export a Crystal Report to a PDF and then use that PDF. But the problem I have is that the export doesn't complete quick enough for my application to use it. Any ideas on the best way to pause my application unitl the export is complete?
Thanks
|
|
|
|
|
Liqz wrote: Any ideas on the best way to pause my application unitl the export is complete?
I take it you are trying to open the PDF but failing because it is still being written to?
What you could do is loop around attempting to open the file. When you manage to open the file you know it is ready. Until then you just loop around again.
Also, be aware that this could potentially introduce an infinite loop in your application if the file handle is never released by Crystal Reports so you will want to build in a time out mechanism so that after attempting for a period of time you give up.
|
|
|
|
|
You can 'halt' the current thread, stopping execution of your code (5 seconds in the example below)
System.Threading.Thread.CurrentThread.Sleep(5000) This will prevent the form from drawing, because your application isn't processing messages. An alternative method would be to put the current time in a variable and enter a loop with a call to Application.DoEvents . Break the loop if a specified amount of time hath expired.
Third possibility is the use of the timer-component
Happy Programming!
I are troll
|
|
|
|
|
Eddy Vluggen wrote: a call to Application.DoEvents
That way madness lies.
|
|
|
|
|
Don't be afraid, and embrace that madness - you don't want to be the last sane person here, do you?
Insanity doth tickle the imagination
I are troll
|
|
|
|
|
Bad solution. Your code assumes that the operation will, forever, take under 5 seconds to complete. A better solution would be to try and open the file with DenyShareAll sharing permissions every so often, say 500 milliseconds, until the file opens. Then you'll know the file is finished writing, no matter how long it takes.
|
|
|
|
|
Normally, I'd reply that any working solution isn't bad, but this is a dirty hack and not a solution. The thing is that you notice that 5 seconds isn't always enough, so you extend the period to 10 seconds. That's kinda cool when the task usually finishes within half a second, leaving you to wait for 9,5 seconds every dang time. How often do you come across a place where the application is waiting, no disk-activity and no cpu-activity?
My train of thought departed from the application. What do you do when you can't change the code to send a message to signal an event? It didn't even cross my mind that one could check the object that the application is working on, I just kept thinking on the same track - where the problem arises.
In short, thanks for showing a better option than the quick-and-dirty 'solution'
I are troll
|
|
|
|
|
Thank you both for your suggestions, they have come in very handy
|
|
|
|
|
Hello
Language VB.net Visual Studio 2005
This sounds like it's should be simple, but I've been working on it all night with no joy. Basically, I need to create a DataGridView on the fly and it will contain a column of various website addresses. However, if I use a HyperLinkColumn then I cant get the cells to contain the URLs. Either all the cells contain the same URL, or each cell contains the correct value - but there's no hyperlink. First top solve it get's a beer (as long as they're in Camden)
I've posted my project here: http://www.camdenconsultancyservice.co.uk/Test/Grrrrr.zip
I've pasted the code below ..... now I need to get some sleeeeeeeeeep.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'---adding columns---
DataGridView1.Columns.Add("ID", "Product ID")
DataGridView1.Columns.Add("Name", "Product Name")
DataGridView1.Columns.Add("Description", "Description")
DataGridView1.Columns.Add("Price", "Price")
'DataGridView1.Columns.Add("Website", "Website")
Dim HyperLinkColumn As New DataGridViewLinkColumn
Dim DataGridViewRow As New DataGridViewRow
With HyperLinkColumn
.Name = "WebsiteColumn"
.HeaderText = "Website"
'.DataPropertyName = "Website" 'this carries the values across
.UseColumnTextForLinkValue = True
'.ReadOnly = False
'.Visible = True
'.Text = "http://www.google.com"
End With
DataGridView1.Columns.Add(HyperLinkColumn)
For i As Integer = 0 To 4
'---create a row---
Dim item As New DataGridViewRow
item.CreateCells(DataGridView1)
With item
.Cells(0).Value = i
.Cells(1).Value = "Product " & i
.Cells(2).Value = "Description of Product " & i
.Cells(3).Value = "99.99"
'.Cells(4).Value = "http://www.evergreenhouse.co.uk" & i
'HyperLinkColumn.Index(i).Text = "http://www.google.co.uk" & i
'HyperLinkColumn.Index(i).Value = "http://www.google.co.uk" & i
HyperLinkColumn.Index
'MsgBox(.Cells(4).Value)
End With
'HyperLinkColumn.Text = "http://www.evergreenhouse.co.uk" & i
'---add the row---
DataGridView1.Rows.Add(item)
Next
End Sub
Private Sub DataGridView1_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellContentClick
If DataGridView1.Columns(e.ColumnIndex).GetType Is GetType(DataGridViewLinkColumn) Then
'Open document by Process.Start().
System.Diagnostics.Process.Start(DataGridView1(e.ColumnIndex, e.RowIndex).Value.ToString)
End If
End Sub
End Class
|
|
|
|
|
OK, this is some really ugly code. I'd recommend using a collection of some kind to hold your data rather than trying to put the data directly into the DGV yourself.
First, you're LinkColumn definition is completely screwed up. It should look something like:
Dim newWebColumn = New DataGridViewLinkColumn
With newWebColumn
' This is the column name in the datatable or
' the property name in the collection that this
' column will get it's data from.
.DataPropertyName = "ProductURL"
.AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells
.HeaderText = "Web Address"
.ActiveLinkColor = Color.White
.LinkBehavior = LinkBehavior.SystemDefault
.LinkColor = Color.Blue
.Trackvisitedstate = True
.VisitedLinkColor = Color.YellowGreen
.Resizable = DataGridViewTriState.True
.ValueType = GetType(String)
End With
columns.Add(newWebColumn)
|
|
|
|
|
How can I create a data report.
The data report that I will will going to be printed if the user want to print
report.I am also creating a guest reservation system but I still have lack of ideas
for system.If someone would give some idea what will I do first.
|
|
|
|