Consulting

Results 1 to 4 of 4

Thread: Solved: Setting ActiveDocument.Saved after Print (IOW: "stop bugging me word!")

  1. #1

    Solved: Setting ActiveDocument.Saved after Print (IOW: "stop bugging me word!")

    Often times I open a document (has lots of field codes) and all I do is print it and then close it. However, every time after I print it, I always get a prompt, "do you want to save the document" upon a close event even though the only thing I did was print it. Kind of annoying.

    Does anyone see problems with re-purposing the FilePrint command to get around the problem?

    [vba]Sub FilePrint()
    oldSaved = ActiveDocument.Saved
    Dialogs(wdDialogFilePrint).Show
    ActiveDocument.Saved = oldSaved
    End Sub[/vba]
    BTW: I am good on the field codes always being updated as they are already handled by a separate "AutoOpen" macro that updates all my fields in StoryRanges upon an open event.

    However, are there other things I am not thinking about that could cause a problem for me?

    Thanks,
    -B

  2. #2
    VBAX Master
    Joined
    Feb 2011
    Posts
    1,480
    Location
    You'll also need to repurpose FilePrintDefault, I believe (the one that doesn't show the dialog), using ActiveDocument.PrintOut.

    And I'm pretty sure this won't give you everything you want in Word 2010 (since printing changes pretty dramatically with the advent of file print/page setup combo under the new workspace concept).

    But I don't think there's an worry in what you want to do above, except that you should always always use Option Explicit, and thus be required to Dim oldSaved as Boolean in that routine.

  3. #3

    Thanks Frosty.

    Thanks Frosty. For anyone out there, this was the code I used.

    [VBA]Sub FilePrint()
    Dim oldSaved As Boolean
    oldSaved = ActiveDocument.Saved
    Dialogs(wdDialogFilePrint).Show
    ActiveDocument.Saved = oldSaved
    End Sub

    Sub FilePrintDefault()
    Dim oldSaved As Boolean
    oldSaved = ActiveDocument.Saved
    ActiveDocument.PrintOut
    ActiveDocument.Saved = oldSaved
    End Sub[/VBA]

  4. #4

    Macro to do Manual Numbering to Style Based Auto Numbering

    Does anyone have a macro that will convert manually typed numbering (or "hard numbering") into auto numbering by applying applicable paragraph styling?

    Ideally what I am trying to accomplish is have the macro loop through each paragraph, and if the starting characters in the paragraph range "look" like numbering then the macro will apply a style (i.e. "Article_L1, etc.) with an auto number component to it.

    Further example:

    1. This is a sentence --> [macro applies Article_L1 style]
    1.1 This is another sentence --> [macro applies Article_L2 style]
    1.1.1 --> This is another sentence --> [macro applies Article_L3 style.]
    etc.
    I have been struggling with the code below trying to get it to work, I think the problem has to do with whitespace in the range, but I am not sure.

    [vba]Sub HardNumberingtoAutoNumbering()
    'draft - this needs alot of work
    Dim i As Long
    Dim oRng As Word.Range
    Dim oParRng As Word.Range

    Set oRng = ActiveDocument.Range
    For i = 1 To oRng.Paragraphs.Count
    Set oParRng = oRng.Paragraphs(i).Range
    With oParRng
    If .Characters.First Like "[0-9]" Then
    .Collapse wdCollapseStart
    .MoveEndUntil Cset:="[a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L ,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z]", Count:=wdForward
    '.Delete - eventually the hard numbering needs to be deleted

    'this doesn't seem like the right way to do it.
    If oParRng Like "#.?" Or _
    oParRng Like "##.?" Then
    .Style = ActiveDocument.Styles("Article_L1")

    ElseIf oParRng Like "#.#?" Or _
    oParRng Like "#.##?" Or _
    oParRng Like "##.#?" Or _
    oParRng Like "##.##?" Then
    .Style = ActiveDocument.Styles("Article_L2")

    'Debugging Purposes
    Else: MsgBox (oParRng & " Not triggered.")
    End If

    End If
    End With
    Next i
    End Sub[/vba]
    Anyone have a macro that functions similarly to this or have pointers on how to make this work in a flexible way (ex: macro indifferent as to whether user typed in the "hard numbering" with spaces or tabs)

    I have attached a template with the "Article..." styles I want to apply
    http://dl.dropbox.com/u/1534325/Normal.dotm

    Regards,
    Brian

Posting Permissions

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