![]() |
|
#1
|
|||
|
|||
![]()
I have a macro, call it A, that calls a second macro, call it B, whose job is to open a file of standardized text, copy its contents, close the file, and paste them into paragraph 3 of the active document (and do some other processing).
This has been working fine for ages. But now it doesn't. Everything stops when B macro opens the file. There is no sign of error, and if I put a message box on the line under the command to open the file, it fails to display. Even if I step through the code, it just stops, no yellow highlight line appears beneath the line of code that opens the file. First part of macro B here: Code:
Dim docCurrent As Document ' variable for the currently open file Dim docBraillePrelim As Document ' variable for the document where we are lifting content from Dim rngCurrent As Range ' variable for content of our current working file Dim rngPub As Range Dim rngBraillePrelim As Range ' variable for content of source file Dim strBraillePrelimName As String ' Variable for name of file to open ' auto-update year mentioned in Braille prelims Dim rngOrg As Range Dim rngOrgName As Range Dim dtYear As Date Dim strDateYear As String strDateYear = CStr(Format(Now, "yyyy")) Dim strYear As String strYear = "[year]" strBraillePrelimName = "G:\Accessible Format Transcription\AUTOMATION TOOLKIT\TOOLKIT FILES\PRELIM TEXT\BRAILLE PRELIMS TEXT.docx" On Error GoTo ErrorHandling ' Open Braille Prelims doc and define range of its contents Set rngCurrent = ActiveDocument.Paragraphs(3).Range.FormattedText ' define target range of insertion of the text Debug.Print rngCurrent Set docBraillePrelim = Documents.Open(fileName:=strBraillePrelimName) Set rngBraillePrelim = docBraillePrelim.Range ' This is the range content of the Braille prelims etc etc Would appreciate any clues as to what might be going wrong, or another way to do the same thing. As I said, the macro stops all activity at Documents.Open, which it successfully does, but there's a lot more to go; |
#2
|
||||
|
||||
![]()
Is there a template containing macros attached to the 'BRAILLE PRELIMS TEXT.docx' document?
If you are importing the entire contents of that document into the activedocument then it might be simpler to import the text from that file.
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
#3
|
|||
|
|||
![]()
Thanks for your response.
There weren't macros attached to the document template, but I did change the template back to Normal.dotm from one of my custom templates, and the offending macro now runs through to completion. No idea just what caused the issue, but happy it's back running. |
#4
|
|||
|
|||
![]() Quote:
|
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
How to make users enable macro before opening the file? | elaineAda | Word VBA | 4 | 02-01-2023 10:25 PM |
Autorun macro when opening the file | Tom cheeseburger | PowerPoint | 2 | 07-07-2021 05:42 PM |
Word file says 'Opening in Protected View' but not opening. | Yakbird | Word | 2 | 07-08-2019 10:55 AM |
start where last session finished | aymanharake | Word | 1 | 03-07-2017 03:08 PM |
![]() |
gmanword | Word VBA | 5 | 11-30-2013 02:55 PM |