1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Visio: Saving Macro for use in preexisting documents

Discussion in 'Business Applications' started by ComfortGroup_IT, Aug 27, 2009.

Thread Status:
Not open for further replies.
Advertisement
  1. ComfortGroup_IT

    ComfortGroup_IT Thread Starter

    Joined:
    Aug 27, 2009
    Messages:
    132
    We have recently upgraded from Visio 2002 to Visio 2007 at work. It seems that there is an issue with the majority of files created in our previous version (2002) where the print size wasn't saved and defaulted back to 8 1/2 x 11 instead of 11 x 17. I found all the information I needed to make the macro to convert all of the pages (code listed at the end) but the only way I found to save it for future use is to save a new file as the template. Unfortunately, that doesn't help me as the files I need to use the macro on are preexisting. Is there a way, in Microsoft Visual Basic, to create a add-on with this macro? Also, if you create a Macro in Word it gives you the option to save it for all documents (Normal.doc) but there doesn't seem to be a corresponding option for Visio. Any help would be greatly appreciated.


    Code:
    Sub pagesetup()
    ' Keyboard Shortcut: Ctrl+q
    '
    Dim pag As Page
    Dim UndoScopeID1 As Long
    'Run through each page in document
    UndoScopeID1 = Application.BeginUndoScope("Page Setup")
    For Each pag In ThisDocument.Pages
    With pag
    .PageSheet.CellsSRC( _
    visSectionObject, _
    visRowPage, _
    visPageWidth).FormulaU = "17 in"
    .PageSheet.CellsSRC( _
    visSectionObject, _
    visRowPage, _
    visPageHeight).FormulaU = "11 in"
    .PageSheet.CellsSRC( _
    visSectionObject, _
    visRowPrintProperties, _
    visPrintPropertiesPaperKind).FormulaU = "4"
    End With
    Next pag
    Application.EndUndoScope UndoScopeID1, True
    End Sub
    
     
  2. ComfortGroup_IT

    ComfortGroup_IT Thread Starter

    Joined:
    Aug 27, 2009
    Messages:
    132
  3. ComfortGroup_IT

    ComfortGroup_IT Thread Starter

    Joined:
    Aug 27, 2009
    Messages:
    132
  4. Rollin_Again

    Rollin_Again

    Joined:
    Sep 4, 2003
    Messages:
    4,912
    So if I understand correctly your issue is that you need to be able to open any Visio drawing and run the macro against it without having to manually save the code to each project before running? Unfortunately Viso does not have a global template similar to the the MS Word template file. You have a couple of options in this situation. If all your Visio projects are saved to the same directory you can create a macro that will loop through all the files in the directory and open them one at a time and make the change before re-saving. The only other option that you have is to attach the code to a blank project and keep it minimized in your taskbar which will make it's code available to all other drawings that are opened. You can then just run the code on the active drawing that currently has the application focus. Another possible option that I have not tested yet it to create a VBS script that when run will look for any running instance of Visio and execute the code on it. I'm installing Visio on my machine now and will play around with it a little later to see which option will work best.

    Regards,
    Rollin
     
  5. ComfortGroup_IT

    ComfortGroup_IT Thread Starter

    Joined:
    Aug 27, 2009
    Messages:
    132
    I know Automated Logic created some macros (I assume they are macros) that are installed as toolbar buttons. One makes a TOC and the other, BOMBuilder, creates a bill of materials, and they all are available for any visio document. It, I believe, is saved as a .vsl file. I was hoping to be able to do something similar. I know there is a way to do it, I just don't know what it takes to do so.
     
  6. Sponsor

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/856015

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice