473,769 Members | 6,473 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Copy and paste into word from access

6 New Member
Hi all,


It's a little late in the day for me so please forgive as i need my bed.!!


The issue is i need to open a word doc (say "c:\temp.do c) and paste into it, but i only can work out how to open a NEW doc
Expand|Select|Wrap|Line Numbers
  1.             ' Creates a new document and pastes Clipboard contents.
  2.           ' Saves the document in the Word directory and closes the
  3.           ' document.
  4.  
  5.  Set NewObject = CreateObject("Word.Basic")
  6.           NewObject.filenew
  7.           NewObject.editpaste
  8.           NewObject.filesaveas DocPath & "\" & NewDoc
  9.           NewObject.FileClose
Sep 29 '09 #1
6 8204
NeoPa
32,573 Recognized Expert Moderator MVP
I'm assuming you're executing this code within an Access module of some kind yes?

Check out Application Automation. There may be some references in there to help.
Sep 29 '09 #2
Paul Mc
6 New Member
Yes i am.

Now i can open the doc but cant figure out how to paste this time round.
Expand|Select|Wrap|Line Numbers
  1. Set NewObject = CreateObject("Word.Application")
  2. NewObject.Visible = True
  3. NewObject.Activate
  4. NewObject.ChangeFileOpenDirectory "D:\"
  5. NewObject.Documents.Open FileName:="Point.dotx"
  6.  
  7.  
  8. 'now not working !!!!!!!!!
  9.          NewObject.Document.editpaste
  10.          NewObject.filesaveas DocPath & "\" & NewDoc
  11.          NewObject.FileClose
  12.  
  13.           ' Frees the memory used by the objects.
  14.           Set NewObject = Nothing
Sep 29 '09 #3
NeoPa
32,573 Recognized Expert Moderator MVP
I think you're looking for :
Expand|Select|Wrap|Line Numbers
  1. Call NewObject.Selection.Paste
where NewObject is an object of type Word.Application.
Sep 29 '09 #4
NeoPa
32,573 Recognized Expert Moderator MVP
@NeoPa
In Excel and Word it is often very easy to determine what code is required to to perform a particular function.

Simply select Tools \ Macro \ Record New Macro and execute the function manually. When complete, just look at the code it produces. It's pretty obvious what each command does and you can use the Help system to refine it, change options & parameters etc.
Sep 29 '09 #5
Paul Mc
6 New Member
How to Extract a embeded OLE word document and paste & save it into an exteranl location

Sorry some sloppy coding!
Expand|Select|Wrap|Line Numbers
  1. Private Sub Command31_Click()
  2.  
  3.           Dim NewObject As Object
  4.           Dim NewDoc As String
  5.           Dim DocPath As String
  6.  
  7.           ' Name of the new document to create.
  8.           Dim Dnam As String
  9.           Dnam = Me.Text32 & ".doc"
  10.           NewDoc = Dnam
  11.  
  12.           ' Where to store the new document.
  13.           ' DefaultDir$(9) returns the Word directory path.
  14.           ' See DefaultDir$() in Word's on-line help for more options.
  15.           ' Note: The "$" is not used when calling DefaultDir via
  16.           ' OLE Automation.
  17.           DocPath = "D:\Kpic"
  18.  
  19.           ' Copies the embedded object to Clipboard.
  20.           Me!Photograph.Verb = 0
  21.           Me!Photograph.Action = 7
  22.           Me!Photograph.Object.Application.WordBasic.EditSelectAll
  23.           Me!Photograph.Object.Application.WordBasic.EditCopy
  24.           Me!Photograph.Action = 9
  25.           DoEvents
  26.  
  27.  
  28.           ' Opens a word template document and pastes Clipboard contents.
  29.           ' Saves to a new file and document in the Word directory and closes the
  30.           ' document.
  31.  
  32. Set NewObject = CreateObject("Word.Application")
  33. NewObject.Visible = True
  34. NewObject.Activate
  35. NewObject.ChangeFileOpenDirectory "D:\"
  36. NewObject.Documents.Open FileName:="Point.dotx"
  37. NewObject.Selection.Paste
  38.          'removes an extra space!
  39.         NewObject.Selection.TypeBackspace
  40.  
  41.          NewObject.ActiveDocument.SaveAs FileName:=DocPath & "\" & NewDoc
  42.  
  43.          NewObject.ActiveDocument.Close
  44.  
  45.           ' Frees the memory used by the objects.
  46.           Set NewObject = Nothing
  47.  
  48.           MsgBox DocPath & "\" & NewDoc & " was created successfully."
  49.       End Sub
Sep 29 '09 #6
NeoPa
32,573 Recognized Expert Moderator MVP
Paul, it's not clear what your intention is posting this code. I'm guessing it's a notification that you now have it working and are politely posting your solution for us to clarify the thread. If so, thank you. We appreciate that attitude. If not, please clarify.

PS. Please remember to use the CODE tags when posting code in future. I have amended each of your posts so far for you and left an edit comment. Using the CODE tags is mandatory on the site.
Sep 29 '09 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

7
2744
by: Bani | last post by:
Is it possible to get browser-menu events (IE) into Javascript? I have a special copy/paste on the onkeydown event (ctrl+c/ctrl+v). Now the users would like to trigger it also from the browser menu.
1
2567
by: Sean Howard | last post by:
Dear All, As is my want I need to do something in Access that seems simple but cannot fathom out. I have main form with two subforms, both datasheets with an almost identical table structure. I want to add the functionality to copy records from subformA to subformB WITHOUT USING COPY/PASTE. The reasonfor this is that I must
4
21626
by: Legendary Pansy | last post by:
I was checking out the 101 C# Samples, specifically Windows Forms - Use the Clipboard. I took a look at the code for a while, and I understand what the program is doing with the cut, copy, pasting via the file menu events using the clipboard. However, what I don't get is how is the program able to produce a context menu in the textbox area. When right clicking, the context pops up and allows to cut/copy/paste/delete, etc.. But the thing is, I...
3
2404
by: Rachel Suddeth | last post by:
This may not be the right forum, but it's a problem I chiefly come across when trying to post here. When I do a copy/paste from VS, the text always looks really weird (and even if I'm in an editor that's supposed to be doing plain text, it looks like it's in a different font -- and of course you can't change the font in a plain text editor.) Then when it gets converted to actual plain text, there is a blank line stuck in between every...
7
11639
by: lgbjr | last post by:
Hello All, I¡¯m using a context menu associated with some pictureboxes to provide copy/paste functionality. Copying the image to the clipboard was easy. But pasting an image from the clipboard is proving to be more difficult. These pictureboxes are bound to an AccessDB. If the user wants to add an image, they select an image using an OpenFileDialog: Dim result As DialogResult = Pic_Sel.ShowDialog() If (result = DialogResult.OK) Then
0
1625
by: Richard Crowley | last post by:
I have a dynamically-generated asp web page which uses Office Web Components to display an Excel bar chart of the user-selected data. The page works fine, but the users would like to copy-n-paste the displayed bar chart from the web page and insert it into an email (MS Outlook) or report (MS Word or MS PowerPoint). Is there any way of supporting this copy/paste functionality? When you right-click on the chart in the displayed web page...
1
2296
by: obeast215 | last post by:
Good Afternoon, I am trying to create a macro that will copy and paste from the 3270 IBM Reflection program to either Microsoft Access database or Microsoft Excel. I already understand the mapping, i.e. column and rows, how to highlight what I want. But I don’t understand how to take that information via macros and paste it into the Access or Excel spreadsheet. I have already learned how to paste from Access to 3270 to run the repetitive...
5
23487
by: deve8ore | last post by:
Hello, I have a Word document called (), a named range that will open up a new Word doc dependent on what a user selects in Excel. Could someone please guide me on how to set up VBA code to copy and paste ALL sheets in the Word doc and paste into Excel? The sheets normally contain a graph or two, so if it's a copy & paste special as a picture, that's fine. Any help would be appreciated. Thank you,
8
15441
by: jh | last post by:
I'd like to copy/paste into a listbox during runtime. I can do this for a textbox but can't figure out how to accomplish this for a listbox. Any help? Thanks.
3
3421
by: questionit | last post by:
Some websites disable the Windows copy and paste feature to use on thier website. A text can not be copied and pasted either from using shortcuts : CTRL+C, CTRL+V or from using copy, paste option from the menu. These website disable copy/paste probably for some safety reasons. What gets changed in the Windows that disables copy/paste feature. Is there anything in Registry that gets changed or anything else or a website uses any ActiveX...
0
9589
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9423
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10049
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8873
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5309
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3965
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3565
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.