Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 04-16-2017, 06:08 AM
rogerbowering rogerbowering is offline Help with Complex VBA program Windows 10 Help with Complex VBA program Office 2010 32bit
Novice
Help with Complex VBA program
 
Join Date: Apr 2017
Posts: 15
rogerbowering is on a distinguished road
Post Help with Complex VBA program

Hi

At work I have to create Report templates using Word and pre-supplied Macro enabled Template (.dotm)

The template provides additional buttons and code to the Word documents I work on



The purpose of the code is to, essentially create a HTML version of the document ('documentname.tmp') in a subdirectory (compiled) of the original working document directory, i.e. //my directory/compiled/ and then it 'compiles' the HTML code into a further sub directory //my directory/compiled/mydocument_files/ and a jsp version of the document.

So I start with
//my directory/myworddoc.docx

and end with
//my directory/myworddoc.docx
//my directory/compiled/createdoc_myworddoc.jsp
//my directory/compiled/createdoc_myworddoc.tmp
//my directory/compiled/myworddoc_files/

For the last year, when I run the code, all the necessary folders and documents are created and I am left with the active docx file on screen.

But now when I run the code I left in the compiled folder with the tmp file as the active document (and the docx file closed).

Can anyone make sense of the VBA and advise if it can be changed to achieve what I need

PS the original coder has now disappeared
Attached Files
File Type: dotm McLarens Document Production Template.dotm (147.4 KB, 20 views)
File Type: txt Document Template VBA and Properties.txt (18.6 KB, 13 views)
Reply With Quote
  #2  
Old 04-24-2017, 04:53 AM
macropod's Avatar
macropod macropod is offline Help with Complex VBA program Windows 7 64bit Help with Complex VBA program Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Your attached template contains over 1000 lines of code. That's a lot to ask anyone to analyse, looking for problems. Some of it seems unnecessarily convoluted, too. For example, you could probably replace the calls to getNameOnly, which invokes:
Code:
Function getCurName() As String
    getCurName = LCase(ActiveDocument.name)
End Function

Function getNameOnly() As String
    Dim testString As String
    Dim lastIndex As Integer
    lastIndex = InStrRev(getCurName(), ".") - 1
    testString = Mid(getCurName(), lastIndex, Len(getCurName()) - lastIndex)
    getNameOnly = Mid(getCurName(), 1, lastIndex)
End Function
with:
Code:
LCase(Split(ActiveDocument.Name, ".doc")(0))
You could most certainly replace statements like:
Code:
ActiveDocument.path + "\" + ActiveDocument.name
with:
Code:
ActiveDocument.FullName
Usually, if the execution behaviour changes, it's because someone has changed the code or done something to the data structures (e.g. file/folder names) that invalidates the assumptions upon which the code works. I suggest you review whatever changes might have been made in those respects.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with Complex VBA program Complex Directory Optional_karl Mail Merge 1 09-29-2016 01:54 PM
Help with Complex VBA program a complex IF formula perhaps? robfreeman Excel 3 05-17-2016 04:58 AM
Help with Complex VBA program I need help for a complex projet at my job Elok Word 4 01-10-2013 08:28 AM
Giant table with numbers, complex text, images: Which program? 8ruk3r Office 2 11-23-2012 05:31 PM
Help with Complex VBA program Complex array formula andrei Excel 9 02-03-2012 03:40 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 10:01 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