+ Post New Thread
Page 2 of 2 FirstFirst 12
Results 16 to 24 of 24
Office Software Thread, Macros in Technical; @ nephilim - did you get it working?...
  1. #16

    LosOjos's Avatar
    Join Date
    Dec 2009
    Location
    West Midlands
    Posts
    5,447
    Thank Post
    1,438
    Thanked 1,168 Times in 797 Posts
    Rep Power
    707
    @nephilim - did you get it working?

  2. #17

    nephilim's Avatar
    Join Date
    Nov 2008
    Location
    Dunstable
    Posts
    11,783
    Thank Post
    1,623
    Thanked 1,877 Times in 1,395 Posts
    Blog Entries
    2
    Rep Power
    422
    havent tested it as I spent the day yesterday in training and today working on a few other higher priority ones. will get too it later

  3. #18

    nephilim's Avatar
    Join Date
    Nov 2008
    Location
    Dunstable
    Posts
    11,783
    Thank Post
    1,623
    Thanked 1,877 Times in 1,395 Posts
    Blog Entries
    2
    Rep Power
    422
    ok, @LosOjos, got a good one for you...

    replace section breaks with page breaks, then print said document, then put back the original section breaks.

    I can get to the point where it prints, but wont replace the original section break.

  4. #19

    LosOjos's Avatar
    Join Date
    Dec 2009
    Location
    West Midlands
    Posts
    5,447
    Thank Post
    1,438
    Thanked 1,168 Times in 797 Posts
    Rep Power
    707
    Quote Originally Posted by nephilim View Post
    ok, @LosOjos, got a good one for you...

    replace section breaks with page breaks, then print said document, then put back the original section breaks.

    I can get to the point where it prints, but wont replace the original section break.
    Hmmm before I look at it, I'm curious as to why? Section breaks are often used for pages that require totally different formatting, such as a landscape page in the middle of a portrait document, or for creating indexes. Both those things would break if the sections were removed, making the print out wrong in the process...

    I suppose what I'm really asking is, what is the end goal? There may be a better solution.

  5. #20

    nephilim's Avatar
    Join Date
    Nov 2008
    Location
    Dunstable
    Posts
    11,783
    Thank Post
    1,623
    Thanked 1,877 Times in 1,395 Posts
    Blog Entries
    2
    Rep Power
    422
    We have a separate software now which deals with the section breaks as it will insert PDFs or Excel spreadsheets etc into where it should go (based on pages). As such not needed anymore.

    However some people add them by habit so it doesn't work with our printing macro and we have to continually help with this. So having a macro or subroutine which will do this in 1 click will save us a lot of time in a working day...both end users and us

  6. #21

    nephilim's Avatar
    Join Date
    Nov 2008
    Location
    Dunstable
    Posts
    11,783
    Thank Post
    1,623
    Thanked 1,877 Times in 1,395 Posts
    Blog Entries
    2
    Rep Power
    422
    I forgot to add...people use it mainly on older documents...not the newer ones. Should have cleared that up a bit.

  7. #22

    LosOjos's Avatar
    Join Date
    Dec 2009
    Location
    West Midlands
    Posts
    5,447
    Thank Post
    1,438
    Thanked 1,168 Times in 797 Posts
    Rep Power
    707
    @nephilim - I still don't understand how this macro would be helpful in any way, sections and page breaks are totally different things... it'd be like writing a macro to replace all the tables in the document with pictures of kittens - not what the author intended (although that sounds like an hilarious prank...)

    However, I still tried! Failed, but tried lol. The code below is my attempt; I can store copies of the sections, replace them with page breaks, but then trying to iterate back trhough the document replacing the new page breaks with the original sections is where I fall down... maybe you can work that bit out from here?

    Code:
    Sub SectionsToPageBreaks()
    Dim i As Integer
    Dim savedSections() As Section
    ReDim savedSections(0 To 0)
    
    With ActiveDocument.Range
        For i = 1 To .Sections.Count
            If .Sections(i).PageSetup.SectionStart <> wdSectionNewColumn Then
                ReDim Preserve savedSections(0 To UBound(savedSections) + 1)
                Set savedSections(UBound(savedSections)) = .Sections(i)
            End If
        Next i
    End With
    
    With ActiveDocument.ActiveWindow.Selection
        ' replace section breaks
        .StartOf wdStory, wdMove
        .Find.Text = "^b"
        .Find.Replacement.Text = "^m"
        .Find.Forward = True
        .Find.Execute Replace:=wdReplaceAll
        
        ' perform any actions you wish to with the newly formatted document here
        MsgBox "Replaced " & Str$(UBound(savedSections)) & " sections."
        
        ' iterate savedSections array, returning section breaks to original positions
        If UBound(savedSections) > 1 Then
            .StartOf wdstroy, wdMove
            .Find.Replacement.Text = ""
            ' skip first section, which is the start of the document
            For i = 2 To UBound(savedSections)
                .Start = savedSections(i).Range.Start
                .Collapse wdCollapseStart
                .Find.Execute
                Select Case savedSections(i).PageSetup.SectionStart
                    Case wdSectionContinuous
                        .InsertBreak wdSectionBreakContinuous
                    Case wdSectionEvenPage
                        .InsertBreak wdSectionBreakEvenPage
                    Case wdSectionNewPage
                        .InsertBreak wdSectionBreakNextPage
                    Case wdSectionOddPage
                        .InsertBreak wdSectionBreakOddPage
                End Select
            Next i
        End If
    End With
    End Sub

  8. #23

    Join Date
    Jul 2013
    Location
    Solihull
    Posts
    127
    Thank Post
    13
    Thanked 23 Times in 18 Posts
    Rep Power
    7
    I use a fair few pretty basic Macros. I sort of cheat as most of my Macros simply create and run Batch files!

    I've posted this before but I shall post again, here's my main use:

    Untitled.jpg

    The 'PowerPing' macro is my fav. Use the drop down box to select the SIMS machine on the network, hit PowerPing and it updates the status bar detailing if it's online or not, whether SIMS is currently in use, the version of SIMS and whether the SOLUS3 agent is installed. Being at the LA and having about 1500 SIMS machines on the network, it's very handy!

    From there you can then delete SIMS.net, uninstall the S3 agent, set the standard Connect.ini etc etc. It all helps to save a bit of time.
    Attached Images Attached Images
    Last edited by MrMat; 4th June 2014 at 05:16 PM.

  9. #24

    nephilim's Avatar
    Join Date
    Nov 2008
    Location
    Dunstable
    Posts
    11,783
    Thank Post
    1,623
    Thanked 1,877 Times in 1,395 Posts
    Blog Entries
    2
    Rep Power
    422
    @MrMat can you post up that set of macros for me please? That would be handy (though I would edit it for other programs we use here).
    @LosOjos I ended up getting it to copy selection to another page, replace the section breaks with page breaks then print that, then close and leave the original unaltered...best solution around for it, but I do appreciate your help. We use a bespoke software here which will insert items into a section break then print, but if they needed to print something using our formatted macros, the section break wouldn't work within the macros. Hence this needing to be done. But thank you anyway.

SHARE:
+ Post New Thread
Page 2 of 2 FirstFirst 12

Similar Threads

  1. Macro and VBA functions
    By randle in forum Windows
    Replies: 10
    Last Post: 9th February 2007, 09:32 AM
  2. Mandatory Profiles and Macros
    By Midget in forum Windows
    Replies: 3
    Last Post: 24th January 2007, 05:07 PM
  3. Excel Macro - Edexcel GCE Exams
    By steve in forum Educational Software
    Replies: 0
    Last Post: 16th May 2006, 02:49 PM
  4. Replies: 2
    Last Post: 12th January 2006, 09:32 AM
  5. Macro Security
    By Ric_ in forum Windows
    Replies: 4
    Last Post: 4th October 2005, 08:59 AM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •