Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 06-02-2016, 09:11 AM
Greengecko Greengecko is offline Import a specific range (bookmarked section) from all Word docs in a selected folder Windows 7 64bit Import a specific range (bookmarked section) from all Word docs in a selected folder Office 2010 64bit
Novice
Import a specific range (bookmarked section) from all Word docs in a selected folder
 
Join Date: Sep 2014
Posts: 7
Greengecko is on a distinguished road
Default Import a specific range (bookmarked section) from all Word docs in a selected folder

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
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Import a specific range (bookmarked section) from all Word docs in a selected folder How to Import range between two string from other document 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
Import a specific range (bookmarked section) from all Word docs in a selected folder Printing specific section dfinch Word VBA 2 06-09-2011 05:10 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 08:24 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft