![]() |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
![]()
Hello,
I'm not a VBA programmer; I do know a fair amount of javascript. Is there a way that the above script can be modified to import a specific range (bookmarked section) from all Word docs in a selected folder? I'd greatly appreciate any help. Here's my first attempt at it. What I'm trying to do is select all files in the folder selected by the user, then import all files in that folder, selecting the Range (bookmark) "pmo": Option Explicit Sub Importer() Dim myFolder As String Dim myFile As String Dim wdDoc As Document Dim docmFiles As Document Application.ScreenUpdating = False myFolder = openFolder If myFolder = "" Then Exit Sub myFile = Dir(myFolder & "\*.docm", vbNormal) Set wdDoc = ActiveDocument While myFile <> "" With Selection.Find.Text = "pmo" End With Selection.MoveDown Unit:=wdLine, Count:=1 Set docmFiles = Documents.Open(FileName:=myFolder & "\" & myFile, AddToRecentFiles:=False, Visible:=False, ConfirmConversions:=False) wdDoc.Range.InsertAfter docmFiles.Range.Bookmarks.Item("pmo") & vbCr docmFiles.Close SaveChanges:=True myFile = Dir() Wend Set docmFiles = Nothing Set wdDoc = Nothing Application.ScreenUpdating = True End Sub Function openFolder() As String Dim oFolder As Object openFolder = "" Set oFolder = CreateObject("Shell.Application").BrowseForFolder( 0, "Choose a folder", 0) If (Not oFolder Is Nothing) Then openFolder = oFolder.Items.Item.Path Set oFolder = Nothing End Function Last edited by Greengecko; 06-02-2016 at 09:44 AM. Reason: added VBA script |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
PRA007 | Word VBA | 1 | 12-18-2015 09:23 PM |
Outlook VBA to move selected email to a public folder | aaroncrt | Outlook | 2 | 10-21-2013 05:11 PM |
Print attachment when it arrive in specific folder with specific subject | visha_1984 | Outlook | 1 | 01-30-2013 10:42 AM |
Returning a specific value when item is selected from a drop-down list | J Press | Excel | 4 | 09-10-2012 06:12 AM |
![]() |
dfinch | Word VBA | 2 | 06-09-2011 05:10 AM |