#1
|
|||
|
|||
Open word document and copy
Hi I am using the following code to open a word document
Sub Open_Word_Doc() Dim intChoice As Integer Dim strPath As String Dim objWord As Object Set objWord = CreateObject("Word.Application") objWord.Visible = True Application.FileDialog(msoFileDialogOpen).AllowMul tiSelect = False intChoice = Application.FileDialog(msoFileDialogOpen).Show 'if the user selects a file If intChoice <> 0 Then 'get the path selected strPath = Application.FileDialog( _ msoFileDialogOpen).SelectedItems(1) 'opens the document objWord.Documents.Open (strPath) End If End Sub I am trying to amend it so that i can copy all the contents of the word document (like Ctrl + A ) and copy it. How can i do that. Thanks in advance. |
#2
|
||||
|
||||
You should name the document as a variable as you open it.
Code:
Dim oDoc as Object Set oDoc = objWord.Documents.Open(strPath) Code:
oDoc.Range.Copy
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia Last edited by Charles Kenyon; 09-13-2022 at 05:00 AM. |
Thread Tools | |
Display Modes | |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
How to Make Userform Copy From One Word Document to Another | Marrick13 | Word VBA | 0 | 03-19-2018 10:45 AM |
look for a specific word in document and copy it to the filename | sylvio | Word VBA | 4 | 03-09-2017 05:53 PM |
Adding tables to Created word document whilst other word document open Help | rpb925 | Word VBA | 18 | 03-30-2016 04:45 PM |
Word Document won't open | neusys | Office | 0 | 09-16-2013 12:05 AM |
Copy from one word document to another no identical | gmurphy | Word | 3 | 09-07-2011 04:28 AM |