Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




Copy And Paste To Word


Is it possible to copy a text from a non-office program and paste that text in a word document using VB?




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Copy And Paste A Word Table With VB To The Same Word Doc.
The subject says it all. I have a word document containing several tables. Using a unique identifier i can browse to the table i want to copy. From there i am stuck. Don't know how to proceed from here. Any ideas?
Thx!
Guus

Copy Paste Name New Range Word Vba
Suppose I had a sentence that I wanted to copy and paste and word. After pasting this sentence in its new location I want to assign it to a range. How would I do this? The following was my attempt at doing this.

VBA:

Dim r as range

selection.copy
Thisdocument.bookmarks("mybookmark").select
r = selection.paste

Copy And Paste From Word To Ascii
Open word document, use wd.editcopy to clipboard. Now I open a ascii file with
Open "xxx.txt" for output as 1
Now, how do I paste the clipboard into this document?

VBA For Word - How Can I See From What Instance I Copy-paste?
How can I determine witch instances of the word application are open and from what instance I'm copying.

Say for instance I've got a word documents in 3 translations open; EN_bla.doc, NL_bla.doc and FR_bla.doc
EN = english NL = Dutch FR = French

With a program I'm making, I want to make a copy from a selection into a new document.
(the copy-paste into a new doc is no problem!)
But I need a control on the name of the document.
Say a selection in nl_bla.doc. How can I see that I've selected data in that dutch document?
Is it something like this left(filename.selection, 3) = "NL_" ????

With kind regards,
WeeMaster

Automated Word Copy Paste
hello out there,

my job is ist to write reports for serveral databases currently. i use some kind of visual basic (with a predefinded, special api) to generate word documents.

sometimes i've to tidy the word documents after generation by starting a word instance with active x and doing some reformatting as creating indexes or something like that.

now i'd need some functionality which allows me to replace string patterns with text from other word documents.
in other words i want to put pathes into my generated word documents, which are in "phase 2" replaced by the content of the complete word documents where the path points to.

any ideas / someone done something like this before?

regards matthias

VB Macro: Copy & Paste Charts To Word
Hello all,

I am writing an application to generate reports. After a huge process I get a workbook full of charts and tables, which I want to paste in a report template where I placed a few bookmarks.

I tried the following code and it worked just fine for the first chart. However, the execution hangs and I cannot paste the rest of my charts.

Anyone can help? Why is the execution stopping? Am I using a correct approach?


Code:
Sub FindnReplaceBookmark()

Set objWord = CreateObject("Word.Application")
Set WordDoc = objWord.Documents.Add("C:Dot1.dot")
Sheets("MyChart").Activate
ActiveChart.ChartArea.Copy
WordDoc.Bookmarks("MyChartBookmark").Range.PasteSpecial Link:=False, & _
DataType:=wdPasteMetafilePicture, Placement:=wdFloatOverText, & _
DisplayAsIcon:=False

'This is where the execution stops, just before I want to copy&paste
'the rest of my charts.

Sheets("AnotherChart").Activate
ActiveChart.ChartArea.Copy
WordDoc.Bookmarks("AnotherChartBookmark").Range.PasteSpecial Link:=False, & _
DataType:=wdPasteMetafilePicture, Placement:=wdFloatOverText, & _
DisplayAsIcon:=False


Set WordDoc = Nothing
Set objWord = Nothing
End Sub
I really appreciate your time and help.

Cheers,
Julián

Automating A Copy And Paste From Excel To Word
At work, I have to come up with a method of making it easy for users of a report to sign off and approve it. I would like it if they could click a button in Excel that will copy and paste a range from 1 sheet, into a Word document that the macro will launch, and send to recipients.

How To Copy And Paste From TextBox To Word Document ?
I use this code to copy selected text from my textbox to the clipboard:
Clipboard.Clear
Clipboard.SetText Text1.Text
Any idea how can I change the code to make it copy and paste in one go in my active Word document at the place where the cursor is located?
Perhaps I need to add Microsoft Word as a reference from the Reference Dialog Box.
dim x as word.application
set x = new word.application
Now I do not know what to do next?
Thank you.

Copy A Graph From Crystal And Paste It In Word
Well I need to know How can i Copy a Graph from Crystal Report Object and paste it in Microsoft Word on Runtime. I tried using the Clipboard Object in visual basic but the data type type mismatch . Im using the RDC and Visual Basic 6.0 . I would like yout help!

Copy Text Into Memory Then Paste Into Word
I have a multi line textbox and a command button on a form. When the user clicks on the button I want the contents of the text box to be copied in memory, so that he can paste the contents into MSword.

Lloyd Dsouza

Help Transfering Word To Excel Without .copy .paste
i have 2 oles, oleword, oleexcel
i want to transfer data between them i can do this wid .copy .paste but that converts the whole ole, and defeats the purpose, i was wondering if there is anyway just to copy the selected / modified data ?

--==|3Lad3==--

Find Word, Then Select Whole Sentence To Copy/paste
Hello,

I used to be a VB programmer but am doing other languages these days. Here's my problem:

I know how to open a document in Word via VBA, and how to search it for the word "shall". But every sentence containing this word must be copied and pasted into another (new) document, as a table. I'm not sure how to proceed.

I've seen code on finding text, but is it "selected" once found? If so, maybe some form of "Selection.Expand" would get the whole sentence? Then Selection.Copy?

Am I on the right track? If anyone's done this, I'd appreciate any help.

Excel-->Word Copy/Paste Range @ Bookmark
Good Afternoon. I desperately need help doing a simple thing. I am trying to use a copied USEDRANGE from Excel and paste it into a BOOKMARK in Word. Sounds simple, but I can not get it done so far. My code just sticks the copied range at the top of the word document. I need to pinpoint it to copy at the InitialAssessment Bookmark. Here's the code:


Code:
Public Sub SendToWord()
Public Sub SendToWord()
Dim CAP As Range
Dim myWord As Word.Application
Dim bkmk As Word.Bookmark
Set CAP = Sheets("InitialAssessments").UsedRange
CAP.Copy
Set myWord = New Word.Application
With myWord
.Visible = True
.Activate
myWord.Documents.Open _
Filename:="C:Documents and SettingschrisvDesktopHBC2Report DocumentHBC Reporting Document.doc"
With .Selection
Set bkmk = myWord.ActiveDocument.Bookmarks("InitialAssessments")
.Select
.TypeParagraph
.PasteAsNestedTable Link:=False, DataType:=wdPasteOLEObject
End With
End With
End Sub
Suggestions??? Please advise

Copy&Paste From Excel To An Embedded Word Doc Page 2
Im Having 2 problems.
1) How do u open the existing document without wiping out previous changes(like the bookmarks I added). The following code seems to create a new word doc instead of using the existing document embedded.

2) How would I Paste spreadsheet range onto Page2? Bookmarks?

The following code is what I have come up with so far:

Excel.ActiveWorkbook.Worksheets(1).Shapes("OBJECT 1").Select
Selection.Verb Verb:=xlPrimary
Excel.Range("Range").Copy
Word.Documents(1).Select
Word.ActiveDocument.Bookmarks(1).Select
Word.Selection.PasteSpecial

Excel.ActiveWorkbook.Worksheets(1).Shapes(1).OLEFormat.Activate
instead of the first two lines of code

Word Macro For Automatic Copy/paste Into New Documents
All,

I often have to deal with Word documents resulting from searching into structured databases. They're all made of a successive number of individuals records presenting the same structure.
Examples:
"Title:
Author:
Abstract

Title:
Author:
Abstract
..."

I'm looking for a Word macro that would copy each individual record into a new Word (a must) document, would then save it (auto name indexing) and close it automatically. So a Word document containing 50 records would be converted into 50 seperate Word documents each containing one record.

Would anyone have an idea on how to proceed with this.

Any help will be greatly appreciated. Thanks

Copy Data From Excel As The Unformat Text THEN Paste It In Ms Word
I'm try to copy the data from Excel then paste it in Ms word as unformat Text

this is my code but for some reason the format of the data is still FORMATTED from excel and my bookmark does not work as well.. please help


Code:
Sub CopyWorksheetsToWord()

Dim r As Range
Dim w As Word.Application
Dim wd As Word.Document
Dim strText As String
Dim icount As Integer

Set w = New Word.Application
Set wd = w.Documents.Open("c: est1.doc")


With wd.Bookmarks("G") ' this bookmark does not work!!!!!
Range("a15").Select
strText = ""
End With
While ActiveCell.Value <> ""

    icount = 1
    strText = strText & ActiveCell.Value
    While ActiveCell.Offset(0, icount).Value <> ""
        strText = strText & " " & ActiveCell.Offset(0, icount).Value
        icount = icount + 1
    Wend
    strText = strText & vbCr
    ActiveCell.Offset(1, 0).Select
    
Wend

w.Visible = True

w.Selection.InsertAfter strText



End Sub

Copy Flex- Paste Into Some Appl. I Cant Remove Alerts From Word...[RSOLVED]
HI, Im using this code to COPY from my app. so the user can PASTE Later somewhere (excel, word..).
But after copy to clipboard and quit word object it fires "do you want to save unsaved file?"

How can i close the document using an object like this??
Displayalerts=false is not working.

This is the code:

----------------------------------------------------------------------------

Code:
Private Sub CopyGrid()
On Error GoTo ErrorHand:
Dim objWord As Object 'instead of Word.Application
Dim objDoc As Object 'instead of Word.Document

Dim strData As String

If objWord Is Nothing Then
Set objWord = CreateObject("Word.Application")
Else
Set objWord = GetObject(, "Word.Application")
End If
DoEvents

With MSFlexGrid1
.Row = 0
.Col = 1
.RowSel = .Rows - 2
.ColSel = .Cols - 1
strData = .Clip
End With

'The Clip property separates Rows with a carriage return. These
'need to be converted to Tabs as well in order to create the Word Table properly.
strData = Replace(strData, vbCr, vbTab)

Clipboard.Clear
Clipboard.SetText strData

'saco las alertas de word

'Create the Word Table by pasting the Grid Text into a document
'and then use the ConvertToTable method
Set objWord = New Word.Application
Set objDoc = objWord.Documents.Add
objDoc.Range.Paste
objDoc.Range.ConvertToTable wdSeparateByTabs, MSFlexGrid1.Rows - 2, MSFlexGrid1.Cols - 1

'Copy the Word Table to the Clipboard. The user can then Paste
'the table into their word documents.
objDoc.Range.Copy
objWord.DisplayAlerts = False

'----------------------- quit word --------------------------
If Not (wd Is Nothing) Then Set wd = Nothing
If Not (objWord Is Nothing) Then objWord.Application.Quit
If Not (objWord Is Nothing) Then Set objWord = Nothing
'------------------------------------------------------------

ErrorHand:
Resume Next
End Sub

Copy Entire MSFlexgrid, So People Can Paste It Later In A Word Doc As Table?[Solved]
I dont know how to do it. My Msflexgrid will always have 8 cols but it may have diferent number of rows each time.
I know how to copy to clipboard as text, but i cant paste that in MSword, it looks bad.

I think i need to create a MSword table and put the msflexgrid data into it, then copy the Msword table to clipboard so later it could be pasted into MSword?

Anyone has some code that shows how to create the table and put the msflex data into it?
And when its done, i know how to put text or pics into clipboard but here i need to copy the whole Ms table to clipboard, is it possible?

Thanks in advance!
Juan.

Copy Content Of Multiple Word Documents And Paste In Single Documet
Hello Everybody...


I am a software tool designer for my organization
Now i am creating in VB that must copy the contents of
multiple word documents and paste in a new single document
That means the new document contains all the contents of
multiple documents

i have done this ... but there is a problem .. which is eating my brain since last 10 days...


when i run that program it is copying the content and pasting in new file...but the problem is .. the second document content is over writing the first one....like that.. at last i can get only the last
document's content in the new file....
this is not what i need
copy 1 file content ..paste in new file.. then insert page break
then the second file content... then page break....like that

Anybody please help me
i am sending the code by Zip file... Trace it ... Refine it
and please send me the solution... byZip file

I am Waiting for ur reply....


For testing.....

Take a new folder for.... Ex: "c:sam"
take one subfolder --- c:samsam1
in that "sam1" place some word documents
when u run the code select the " Sam" folder only by using dir-control
it creates a new document "single1.doc" in "Sam" folder only

Thank U

Copy Content Of Multiple Word Documents And Paste In Single Documet
Hello everybody
I am a software tool designer for my organization
now i have to create a tool in VB that must copy
contents of multiple word documents and paste in a single document one after other..I have done this.. but there is a problem and that is eating my brain since last 10 days
when i do this .. the program compile very good...
but i did't get the exact result...my code is copying contents and
pasting in one single file..but the next content is over writing the first one..at last i am getting last file content

but this is not what i need..

can anybody help me to do this...

copy first file content... paste in new file..then insert page break
second file content must be pasted after the page break...

i am sending the project Zip file...
Please foll it refine it and send me

Thank u
waiting for ur reply...

For testing.....
Take a new folder for Ex: "c:sam"
take one subfolder --- c:samsam1
in that "sam1" place some word documents
when u run the code select the " Sam" folder only by using dir-control
it creates a new document "single1.doc" in "Sam" folder only

Thank U

VB, MS Word Macro - Prompt # Of Tables Wanted, Copy + Paste # Of Tables
I have a Microsoft Word document that contains a table with form fields.

I would like it set up so that when the user first opens up the document, Microsoft Word prompts the user "how many additional tables" they want in addition to the one that already exists in the document.

The macro would then select and copy, then paste the table "that many times" underneath.

Unfortunately I don't know much about Visual Basic. On the bright side, I do know how to make macros in Word. Can anyone here help me out?

Copy Paste / Copy To Cilp Board..
Is it possible to Copy and paste to a Picture Box?
---OR---
Copy from a picture box to Clipboard. Or even save as a pcx or jpg/gif file?...

Thanks...

Copy And Paste
I am trying to copy a gif from windows explorer and pasting it into VBs Image Control and can't get it to paste. This is what I am trying.

Private Sub mnuMemPaste_Click()
Set frmMembers.Image1 = Clipboard.GetData
frmMembers.Image1.Refresh
End Sub

and nothing is getting pasted
Image1 Control:
Drag Mode = Automatic
OLEDrag mode = Automatic
OLEDrop mode = Automatic

The user right clicks on the image control then a context menu popup with a choice copy or paste. Click the paste command sends you frmmain.mnumempaste.

Copy/Paste
I'm not sure if this is a VBA issue, but I thought I would give it try and see if anyone has run into the same issue.

We upgraded to Word 2000 this past June (we don't like to be trend setters) from Word95. Some of the users have problems going back and forth between documents when trying to copy and paste - their machines lock up.

Some of the lock-ups occur when the user is toggling between documents when they use the drop down Window, some are having the problem when they toggle between documents by clicking on the documents located on the bottom of their toolbar, and others have the problem when using Ctrl F6. It's not a universal problem.

Any thoughts? Thanks!

Copy/Paste
Unfortunately Copy/Paste in my workbook needs to be altered. When a user copies data, I need to validate that data and perform certian functions.

Originally I tried to just use "If cutCopyMode = 1 then..." but that doesn't seem to work the way I need it. Also, I would need to trap the enter key event(s) if the user was 'cuting' data to also perform these functions.

What I would like to know is if anyone else has had to replace / alter excel's cut/copy/paste logic and if there is anything I should be worried about.

I started writing procedures to capture 'OnKey' events as well as the menu driven events. But as I mentioned earlier, I need to also capture the enter key(s) event. If this is the only way to go, is there anything that should be going on if the user hit's the enter key(s) besides changing the offset?

-Jeff

Copy/paste
I really need some help I'm on a deadline and I have to find a way to copy specific info from word and paste it in excel. I know what comes before and after the word or number I need does any one know how to do this.


I apoligize in advance this might be a double post but my previous post havent been really clear so I wanted to give a clear idea of what I want to do.

Copy And Paste
An Excel-document with 2 sheets, the first one is filled out like this:

Column A, Column B, etc.

Product A, 15kg, Red
Product B, 17kg, Blue
Product C, 20kg, Green

The second sheet is always empty when the document is opened.

You mark a productname, or several, and press a commandbutton, located on the first sheet, i want VB to copy the marked productnames and its info onto the second sheet, starting to fill it with info from the top.

I am new to VB so i would really appreciate specific code to get me started.
Thanks in advance.
G

Cut, Copy, And Paste
I Cant Seem 2 Get My Cut Copy And Paste Menu Buttons Working. Heres My Code:


Code:
'Cut
Private Sub mnuCut_Click()
Clipboard.Clear
If rtbText.SelLength = 0 Then
rtbText.SelStart = 0
rtbText.SelLength = Len(rtbText.Text)
End If
Clipboard.SetText Screen.ActiveControl.SelText
Screen.ActiveControl.SelText = ""
End Sub


Code:
'Copy
Private Sub mnuCopy_Click()
Clipboard.Clear
Clipboard.SetText Screen.ActiveControl.SelText
End Sub


Code:
'Paste
Private Sub mnuPaste_Click()
SelText = Clipboard.GetText
End Sub

Cut/Copy/Paste
I have a MDI form and some MDI Childs forms.
I want to implement Cut/Copy/Paste in the program.
I want to know how can i retrieve the handle of the textbox that has the current focus in the program so that I can cut/copy/paste/select all ?

Copy And Paste
Hello! I hope this hasn't been disscussed before...if it has just send me the link and delete this post. (i haven't found such a thread tho')

I wanna' develop a VB application which has to take some information from a web page. I want this to be done by selecting the whole page (Ctrl+A) in the users browser then paste it into the program...when he pastes the page only certain areas of the text in the page need to be pasted into the available text boxes. (not necessarily text boxes...) I want these text areas to be selected automatically by the application without the user having to manually enter each information into each of the text boxes.

Got any ideea how to do this?

For example let's say the following is the text from the web page:

>>Phone Number: 40334421
>>Name: Will Smith
>>Comments: Actor

When I paste the whole text into the VB application i want only 40334421 to be pasted into the txtPhnNo textbox, the Will Smith pasted into the txtName textbox and Actor pasted into the txtCmnt text box.
I hope you undesrtand where I'm going with this.

Thanks

P.S. I work with VB 6.0

Copy And Paste
I have created a simple program in visual basic that checks data entered to make sure its in a certain format. Is is possible for this program to be modified so that it can copy the data entered and paste it in anouther program for example notepad?

Copy And Paste
Hello,
I am trying to implement the Copy and Paste functions. I got "the selecting the text" part done but I am having trouble pasting the text. That is, my question is how do we refer to the position the mouse is at. And since I am trying to do the paste on a text box how do I implement this ?

For example, I can't do something like Text1.Text = Text1.Text + Text1.SelText.

Any advice?

Copy &gt; Paste
I Have two web browsers

Web Browser one displays just text
Web Browser two displays a text box

Is there any way that when I Copy the text in Web Browser one, it automaticlly pastes in web browser 2?

Thanks

Vba Copy And Paste
I am selecting a range out of worksheet and copying it to another. the worksheet is saved with protection after the macro runs the workbook closes itself and when I reopen it the sheet is no longer protected. Why is it doing this and how can I stop it? I don't want to save the sheet with the macro because I do not want to save the new data on the sheet.

Copy/Paste Huh?
let say you have a macro that copys and paste stuff in a huge worksheet. takes 5 min to run.

while the macro is working you go on the web and ctrl-c an article from bbc.com

when i press ctrl-v i get text from my worksheet instead of the article. While my excel sheet has my bbc article on it. WTH!

Copy And Paste
I want to prevent the user from copy and paste how do i do that using vb?

Copy And Paste
Hey everyone,
simple question. How do you make a listbox capable of Ctrl+C (copy)?
Also, along the same lines, how do you make it Ctrl+X (cut) and Ctrl+V (paste)

And one other thing. Is it possible to have a code/script/macro that can automatically take info from my program and enter it in to a web-site, say like E-bay. I'm trying to simplify some of my web browsing by having a program automatically enter username/password. Like I have a selection choice in my program for "Hotmail". When selected, I need it to take the settings from the "Hotmail" area and automatically prefill it into the Hotmail website for me. Is that even possible?

Thanks all!

Copy And Paste !!!!
I am new to VB , not completed anything that works as yet....
Mainly because i'm asking too much of myself....maybe the idea I have for my next one is too much also , could you give me a rating for the below ? Beginner , medium etc..

Project :

Be able to store all "copied" (with right mouse click) into one word document , so you can go back to earlier copies etc


Sound easy , But is it ?


Rgds

Cut, Copy, Paste, Etc How Can U Do Them
hey, i was just trying to figure out how to add a button in vb that when pressed copies, cuts, pastes or watever with a bit of text

could someone help

Copy And Paste
hi i need ny program to copy a file like "new word.txt" to somewhere like "C:word documents" and call it's self "Text1.txt" insted of "New word.txt" i hope you know what i mean. so i want the program to get the file it has made and make a copy to "C:word doucumentsText 1.txt" ok it's not a save command but like a log book.
thanks

Cut, Copy And Paste
hi

i know that using

clipboard.settext txtbox.seltext

and

txtbox.seltext=clipboard.gettext()

will copy and paste text to and from clipboard and txtbox.

what can i do so that this will work for other textboxes?

thx

Copy,paste,cut
i need a menu to be able to cut,copy,paste text in a textbox.......
how do i acomplish this?

Cut Copy Paste - Please...
I am still not quite sure of, nor do I understand the code for 'cut, copy, paste, and undo'. I have had lots of help from people, and lots of different code, but I still fail to get it to work.

I have menu items
mnuCopy
mnuCut
mnuPaste
mnuUndo
All I really want them to do is cut, copy, paste, and undo. Is there some way that I can call "ctrl + X" when user clicks mnuCut?

I know this code is probably very simple, and I am making it difficult for myself, but is there anyone who can show me how to do this? It would be great.

Thanks.

-UseTheMan

CUT, Copy, PASTE
How would I write the code for cut, copy and paste commands?

Would I just use seltext method somehow?

Thanks

-UseTheMan

COPY AND PASTE
I have a menu on my application and I want to enable de paste menu only if there is something on the clipboard

how can I do this?????

A code will be really helpful

Copy &amp; Paste
Ok..this may seem dumb..but I am fairly new to VB so i was wondering If anyone can tell me how to scipt COPY & PASTE on my menu bar.

I used Visual Studio to do the menu abr but now trying to get the buttons to work is becoming mroe difficult than anticipated...any help would be HIGHLY appreciated

THNX

Cut, Copy And Paste
i am making a notepad thing and i want to have cut, copy and paste in the menu. Apparently you cannot do this with the textbox i have because it does not support the sel argument. however if i right click the selection on the textbox, it cuts, copys and pastes the text. How would i simulate the right click -copy or paste etc in my code.

Copy And Paste
I need some help with copy and paste. I have a sstab that is loaded with labels ranoamly placed on the sstab at run time. Tabs are added when no more labels will fit. I need to know if i can copy and paste (or drag and drop)one the the labels from one tab to another tab.

Copy And Paste From One HD To Another
i would like to copy and paste a file from one hard drive to another using a program made in visual basic. i have used a driveListbox, a DirListBox and a FielListBox to show files from a selected directory.. can someone please tell me the code to copy and paste a fiel which is selected in the FileListBox.


Code:
Private Sub Dir1_Change()
File1.Path = Dir1.Path
End Sub

Private Sub Drive1_Change()
Dir1.Path = Drive1.Drive
End Sub

Private Sub File1_Click()
Copy File1.FileName
Paste File1.FileName
End Sub

Thanks

Sam

Copyright © 2005-08 www.BigResource.com, All rights reserved