Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 06-11-2017, 04:37 AM
bnyamin bnyamin is offline create EndNote with vb Windows 7 64bit create EndNote with vb Office 2010 64bit
Advanced Beginner
create EndNote with vb
 
Join Date: Oct 2014
Posts: 36
bnyamin is on a distinguished road
Question create EndNote with vb

hello


i need create word file with combine two file 1 and 2 in attach files
endendnote and startendnote = are codes in body text
Attached Files
File Type: txt befor run vb1.txt (215 Bytes, 12 views)
File Type: docx after run vb.docx (14.3 KB, 11 views)
File Type: txt befor run vb2.txt (334 Bytes, 13 views)
Reply With Quote
  #2  
Old 06-11-2017, 07:00 AM
gmaxey gmaxey is offline create EndNote with vb Windows 7 32bit create EndNote with vb Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,600
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

Something like this:

Code:
Sub ScratchMacro()
'A basic Word macro coded by Greg Maxey
Dim oDict
Dim oDocNotes As Document, oDocText As Document
Dim oRng As Range
Dim strNote As String
Dim oNote As Endnote
  'Create a dictionary containing the defined endnote text.  Note references "must" be unique.
  Set oDict = CreateObject("Scripting.Dictionary")
  Set oDocNotes = Documents.Open("C:\Users\Maxey\Desktop\befor run vb2.txt", , , False, , , , , , , , False)
  Set oRng = oDocNotes.Range
  With oRng.Find
    .Text = "(endendnote)(*)(startendnote)"
    .MatchWildcards = True
    .Replacement.Text = "\2"
     While .Execute(Replace:=wdReplaceOne)
       strNote = oRng.Paragraphs(1).Range.Text
       strNote = Trim(Replace(strNote, oRng.Text, ""))
       oDict.Add oRng.Text, strNote
       oRng.Collapse wdCollapseEnd
     Wend
  End With
  oDocNotes.Close wdDoNotSaveChanges
  'Open the text document and replace the flags with the matching dictionary item
  Set oDocText = Documents.Open("C:\Users\Maxey\Desktop\befor run vb1.txt")
  Set oRng = oDocText.Range
  With oRng.Find
    .Text = "(endendnote)(*)(startendnote)"
    .MatchWildcards = True
    .Replacement.Text = "\2"
     While .Execute(Replace:=wdReplaceOne)
       Set oNote = ActiveDocument.Endnotes.Add(oRng, oRng.Text, oDict.Item(oRng.Text))
       If Asc(oNote.Range.Characters.Last) = 13 Then
         oNote.Range.Characters.Last.Delete
        End If
       oRng.Delete
     Wend
  End With
lbl_Exit:
  Exit Sub
End Sub
P.S. before is spelled with an ending e
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #3  
Old 06-11-2017, 02:51 PM
bnyamin bnyamin is offline create EndNote with vb Windows 7 64bit create EndNote with vb Office 2010 64bit
Advanced Beginner
create EndNote with vb
 
Join Date: Oct 2014
Posts: 36
bnyamin is on a distinguished road
Default

Thank you for your guidance and support.
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to use Endnote in powerpoint leehoong2010 PowerPoint 0 07-09-2013 01:08 PM
create EndNote with vb can't get rid of endnote gib65 Word 2 04-17-2012 07:22 AM
end note, not EndNote tomsan Word 3 03-08-2012 12:58 PM
create EndNote with vb Endnote in footnote? kerstin Word 2 06-26-2011 11:23 PM
endnote and import reference from word to endnote uncung Word 0 06-18-2011 08:09 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 09:29 AM.


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