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 - ' Creates a new document and pastes Clipboard contents.
-
' Saves the document in the Word directory and closes the
-
' document.
-
-
Set NewObject = CreateObject("Word.Basic")
-
NewObject.filenew
-
NewObject.editpaste
-
NewObject.filesaveas DocPath & "\" & NewDoc
-
NewObject.FileClose
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.
Yes i am.
Now i can open the doc but cant figure out how to paste this time round. - Set NewObject = CreateObject("Word.Application")
-
NewObject.Visible = True
-
NewObject.Activate
-
NewObject.ChangeFileOpenDirectory "D:\"
-
NewObject.Documents.Open FileName:="Point.dotx"
-
-
-
'now not working !!!!!!!!!
-
NewObject.Document.editpaste
-
NewObject.filesaveas DocPath & "\" & NewDoc
-
NewObject.FileClose
-
-
' Frees the memory used by the objects.
-
Set NewObject = Nothing
NeoPa 32,573
Recognized Expert Moderator MVP
I think you're looking for : - Call NewObject.Selection.Paste
where NewObject is an object of type Word. Application.
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.
How to Extract a embeded OLE word document and paste & save it into an exteranl location
Sorry some sloppy coding! - Private Sub Command31_Click()
-
-
Dim NewObject As Object
-
Dim NewDoc As String
-
Dim DocPath As String
-
-
' Name of the new document to create.
-
Dim Dnam As String
-
Dnam = Me.Text32 & ".doc"
-
NewDoc = Dnam
-
-
' Where to store the new document.
-
' DefaultDir$(9) returns the Word directory path.
-
' See DefaultDir$() in Word's on-line help for more options.
-
' Note: The "$" is not used when calling DefaultDir via
-
' OLE Automation.
-
DocPath = "D:\Kpic"
-
-
' Copies the embedded object to Clipboard.
-
Me!Photograph.Verb = 0
-
Me!Photograph.Action = 7
-
Me!Photograph.Object.Application.WordBasic.EditSelectAll
-
Me!Photograph.Object.Application.WordBasic.EditCopy
-
Me!Photograph.Action = 9
-
DoEvents
-
-
-
' Opens a word template document and pastes Clipboard contents.
-
' Saves to a new file and document in the Word directory and closes the
-
' document.
-
-
Set NewObject = CreateObject("Word.Application")
-
NewObject.Visible = True
-
NewObject.Activate
-
NewObject.ChangeFileOpenDirectory "D:\"
-
NewObject.Documents.Open FileName:="Point.dotx"
-
NewObject.Selection.Paste
-
'removes an extra space!
-
NewObject.Selection.TypeBackspace
-
-
NewObject.ActiveDocument.SaveAs FileName:=DocPath & "\" & NewDoc
-
-
NewObject.ActiveDocument.Close
-
-
' Frees the memory used by the objects.
-
Set NewObject = Nothing
-
-
MsgBox DocPath & "\" & NewDoc & " was created successfully."
-
End Sub
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.
Sign in to post your reply or Sign up for a free account.
Similar topics |
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.
|
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
|
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...
|
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...
|
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
| |
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...
|
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...
|
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,
|
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.
|
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...
|
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...
| |
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,...
|
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...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
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...
| |