473,386 Members | 1,706 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Word ActiveWindow Selection Copy failing

Hi,

I've got this bit of code off the interweb and everyone and their dog
says it should work. But it doesn't... For some reason the line
wordDoc.ActiveWindow.Selection.Copy() doesn't copy anything into the
clipboard so the line fileContent =
data.GetData(System.Windows.Forms.DataFormats.Text ).ToString() fails
daying data is nothing.

Has anyone else had this problem or am I just special??

Thanks

Gareth

Private Function extractWordFileText(ByVal filename As String) As
String
Dim fileContent As String
Dim wordApp As New Word.ApplicationClass
Dim nullObject As Object = System.Reflection.Missing.Value

Dim wordDoc As Word.Document = wordApp.Documents.Open(filename, _

nullObject, _

nullObject, _

nullObject, _

nullObject, _

nullObject, _

nullObject, _

nullObject, _

nullObject, _

nullObject, _

nullObject, _

nullObject, _

nullObject, _

nullObject, _

nullObject)

wordDoc.ActiveWindow.Selection.WholeStory()
wordDoc.ActiveWindow.Selection.Copy()

Dim data As System.Windows.Forms.IDataObject =
System.Windows.Forms.Clipboard.GetDataObject()
fileContent =
data.GetData(System.Windows.Forms.DataFormats.Text ).ToString()
wordDoc.Close()
End Function

Jul 27 '06 #1
0 1988

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: David Krmpotic | last post by:
Regards, I need a little explanation in converting word VB macros to charp code! first, I recorded simple macro which replaces every occurence of one word in whole document (is it?) , here:...
2
by: Mikey | last post by:
Sample VB .NET source code to create mailing labels or customized letters using MS Word MailMerge This VB .NET source code will start MS Word and call methods and set properties in MS Word to...
3
by: Anne Richmond | last post by:
The following code creates a word document. How do I add a footer to each page containing the date and page number? Dim wrdApp As Word.Application Dim wrdDoc As Word.Document Dim...
0
by: Alto_chn | last post by:
I want to display the content of a word document in a text box when the filename is highlighted on a listbox. i used the following code to do it: Dim app As Word.Application app = New...
0
by: hinew | last post by:
Hi. I have created macro for Microsoft word. However I need this to be run in visual baisc application. I need a program that ask user to select the word document which need to be processed....
3
by: Jay | last post by:
Hi, I need to read word document file in ASP.net and place it in a text box . How to do it ? i tried : Word.Application app = new Word.ApplicationClass(); object nullobj =...
0
by: funeeldy | last post by:
I need to locate a particular table in a document. I cannot hardcode the table number since it could be different in every doc. I do have some header text that comes right before it consistently,...
4
by: etuncer | last post by:
Hello All, I have Access 2003, and am trying to build a database for my small company. I want to be able to create a word document based on the data entered through a form. the real question is...
0
by: dbsog7777 | last post by:
I was trying to use the sample code below, but I encountered two errors: Application.DoEvents() and AutoText(entry). I am not sure how to correct the errors. I trying to use the sample code to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.