Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 07-04-2014, 08:49 PM
smndnm smndnm is offline How to invoke the macro correctly in the workflow Windows 7 64bit How to invoke the macro correctly in the workflow Office 2010 32bit
Novice
How to invoke the macro correctly in the workflow
 
Join Date: Jul 2014
Location: Queensland
Posts: 24
smndnm is on a distinguished road
Question How to invoke the macro correctly in the workflow

Hello,



I am struggling with understanding of when (and how) to invoke a macro correctly in my intended workflow.

My workflow goes:

  • Open and populate doc123.docx
  • Open one of the many docABC.dotm (intially and correctly as Document1.docx), which updates its links from doc123.docx
  • Click save (which would ordinarily invoke the SaveAs dialog, however...) - which automatically runs this macro:- (which forces a name and filetype change, it also directs the filesave location to a predetermined place, it also updates the Subject and Title properties) Many thanks go to Paul Edstein for most of this code.

Code:
Sub Document_New()
'
' Demo Macro
'
'
Dim StrNm As String
Dim DocSubject As String
With ActiveDocument
StrNm = "SWMS " & .Bookmarks("docnumber").Range.Text & " " & _
  .Bookmarks("doctype").Range.Text & " - " & _
  .Bookmarks("sitename").Range.Text & " - " & _
  .Bookmarks("personname").Range.Text

DocSubject = .Bookmarks("doctype").Range.Text

.BuiltInDocumentProperties("Title") = StrNm
.BuiltInDocumentProperties("Subject") = DocSubject
End With

With Application.Dialogs(wdDialogFileSaveAs)
    .Name = StrNm
    .Format = wdFormatPDF
     Options.DefaultFilePath(wdDocumentsPath) = "C:\folderA\folderb
    .Show
End With
End Sub
My questions are:
  1. what code is required to get this macro to run at the required instant? (my confusion here is the new Document1.docx is not where the macro was saved to)
  2. Why does the changed Title property not appear in the filename dialog box? (at this stage I am forced to use .Name = StrNm which is not an issue, but perhaps is not so elegant a solution)
  3. Is the code layout correct?
Your thoughts please.
Regards from a bright and sunny Queensland.
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to invoke the macro correctly in the workflow Suggestions wanted for improving workflow of shared incoming emails plaidma1 Outlook 1 05-03-2013 09:33 AM
How to add a file menu item and invoke an EXE? simplyarun PowerPoint 0 07-21-2011 01:59 AM
How to invoke the macro correctly in the workflow margins don't set correctly dawit Word 1 05-10-2011 09:47 PM
How to invoke the macro correctly in the workflow TOC Not Updating Correctly Nigel1985 Word 1 05-27-2010 07:19 PM
How to invoke the macro correctly in the workflow workflow silviu Office 1 05-21-2009 11:12 AM

Other Forums: Access Forums

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