Results 1 to 12 of 12
  1. #1
    Lounger
    Join Date
    Jul 2005
    Location
    Bangkok, Bangkok Metropolis, Thailand
    Posts
    39
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Finding and deleting a blank page (2003)

    We have a reporting system for students that allows teachers to enter free text in a Word document template. This template also contains macros that insert grades, names etc.

    Quite often blank lines are added and a blank page is generated and printed. The printing is automatic and up to 50 documents are printed as a batch.

    I have a macro that can detect a blank page and the blank will not print out, but the macro must be activated from an open document.

    Question: Can I embed the macro in the template so that it is called with every document?

    A copy of the macro

    Sub RemoveBlankPages()

    ' RemoveBlankPages Macro
    ' Macro recorded 09/03/2007 by Martin Taylor (credit where it's due)

    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
    .Text="^m^m"
    .Replacement.Text="^m"
    .Forward=True
    .Wrap=wdFindContinue
    .Format=False
    .MatchCase=False
    .MatchWholeWord=False
    .MatchWildcards=False
    .MatchSoundsLike=False
    .MatchAllWordForms=False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    ActiveDocument.PrintOut
    End Sub

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Finding and deleting a blank page (2003)

    You could create a DocumentBeforePrint event procedure, or create FilePrint and FilePrintDefault macros. See the thread starting at <post:=217,270>post 217,270</post:> for examples of both.

  3. #3
    Lounger
    Join Date
    Jul 2005
    Location
    Bangkok, Bangkok Metropolis, Thailand
    Posts
    39
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Finding and deleting a blank page (2003)

    Thanks Hans I'll give that a go, although at this point I'm not sure how to find the event procedure you mention.

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Finding and deleting a blank page (2003)

    DocumentBeforePrint is an application level event. Type withevents in the Visual Basic Editor and press F1 for help, and/or look at <post:=203,498>post 203,498</post:> for an example (involving another application event).

  5. #5
    Lounger
    Join Date
    Jul 2005
    Location
    Bangkok, Bangkok Metropolis, Thailand
    Posts
    39
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Finding and deleting a blank page (2003)

    Thanks again Hans. That looks pretty manageable.

    A really silly omission on my part, this year the software is using xml instead of doc formats for its templates. Does this make a difference? Again, sorry I forgot.

  6. #6
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Finding and deleting a blank page (2003)

    > this year the software is using xml instead of doc formats for its templates. Does this make a difference?

    XML usually needs to be opened in an application. Is it being opened in Word, IE, or some other host?? The specific format will determine whether it is possible to store any kind of code in the document. Of course, it' may be possible to store the code outside the document and use the code to operate on the document....

  7. #7
    Lounger
    Join Date
    Jul 2005
    Location
    Bangkok, Bangkok Metropolis, Thailand
    Posts
    39
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Finding and deleting a blank page (2003)

    The software is SIM.net for schools and a basic template is created in .xml and opened in Word, result tags (to collect results from other areas) are entered by the user and then saved, this saves as an .xml file.

    When it's time for printing, SIMS.net gives a choice of students that the user selects and the 'Print' button is pushed and the reports print.

    I was thinking that the macro could be saved in the .xml template, which will then apply for every report generated on that template.

  8. #8
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Finding and deleting a blank page (2003)

    If you examine the top of the XML file in a text editor, does it say that it uses the WordML format or other Microsoft Office format? If not, it seems unlikely that it can accommodate macros. I've never create a WordML file, but I believe Microsoft has documented the formats on its web site.

  9. #9
    Lounger
    Join Date
    Jul 2005
    Location
    Bangkok, Bangkok Metropolis, Thailand
    Posts
    39
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Finding and deleting a blank page (2003)

    If I open the xml file created it has the following at the top:

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <?mso-application progid="Word.Document"?>
    <w:wordDocument xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w10="urn:schemas-microsoft-comffice:word" xmlns:sl="http://schemas.microsoft.com/schemaLibrary/2003/core" xmlns:aml="http://schemas.microsoft.com/aml/2001/core" xmlns:wx="http://schemas.microsoft.com/office/word/2003/auxHint" xmlns="urn:schemas-microsoft-comfficeffice" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:wsp="http://schemas.microsoft.com/office/word/2003/wordml/sp2" xmlns:st1="urn:schemas-microsoft-comffice:smarttags" w:macrosPresent="no" w:embeddedObjPresent="no" wcxPresent="no" xml:space="preserve"><w:ignoreElements w:val="http://schemas.microsoft.com/office/word/2003/wordml/sp2"/><o:SmartTagType

  10. #10
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Finding and deleting a blank page (2003)

    Here's the MSDN section on the Office 2003 XML features and formats: XML in Office 2003

  11. #11
    Lounger
    Join Date
    Jul 2005
    Location
    Bangkok, Bangkok Metropolis, Thailand
    Posts
    39
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Finding and deleting a blank page (2003)

    Thanks jscher

    This has sort of ended my quest and I guess this thread, BUT has opened a whole new world of adventure with xml.

    Is there an xml section in Woody's Lounge? I'll have a look in a minute.

  12. #12
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Finding and deleting a blank page (2003)

    No, we don't have a special XML section, since we haven't gotten many questions about it yet.

Posting Permissions

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