Results 1 to 10 of 10
  1. #1
    3 Star Lounger
    Join Date
    Jul 2002
    Location
    Edison, New Jersey, USA
    Posts
    215
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Opening a blank Doc. (Word XP)

    In my macro, I copied some text, and I want to open a new document and past it/ manipulate it. Can that be done?
    I was able to record it as such, but when I ran the macro, all of the actions took place in the original document.

  2. #2
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Opening a blank Doc. (Word XP)

    That sound pretty simple, really. Copy text to the clipboard from one document
    then paste it into a new blank doc? Post your macro code. It might provide a clue.
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  3. #3
    3 Star Lounger
    Join Date
    Jul 2002
    Location
    Edison, New Jersey, USA
    Posts
    215
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Re: Opening a blank Doc. (Word XP)

    Here's the code. I recorded it in 2000. ( I don't think it should make a difference on this topic)

    I recorded most of the script and went back in to start commenting the sections. Fron what I can read in the code, it didn't record anything that would have opened a new doc. You'll see by my comment, where it's supose to be. - J

    Sub RTMCreate4()
    '
    ' RTMCreate4 Macro
    ' Macro recorded 4/15/2003 by SanBill
    '
    Selection.EndKey Unit:=wdStory
    With ActiveDocument
    .TablesOfContents.Add Range:=Selection.Range, RightAlignPageNumbers:= _
    True, UseHeadingStyles:=True, UpperHeadingLevel:=4, _
    LowerHeadingLevel:=9, IncludePageNumbers:=False, AddedStyles:= _
    "Heading 1,1,Heading 2,2,Heading 3,3", UseHyperlinks:=True, _
    HidePageNumbersInWeb:=True
    .TablesOfContents(1).TabLeader = wdTabLeaderDots
    .TablesOfContents.Format = wdIndexIndent
    End With
    Selection.Find.ClearFormatting
    Selection.Find.Style = ActiveDocument.Styles("TOC 1")
    Selection.Find.ParagraphFormat.Borders.Shadow = False
    With Selection.Find
    .Text = ""
    .Replacement.Text = ""
    .Forward = False
    .Wrap = wdFindAsk
    .Format = True
    .MatchCase = False
    .MatchWholeWord = False
    .MatchWildcards = False
    .MatchSoundsLike = False
    .MatchAllWordForms = False
    End With
    Selection.Find.Execute
    Selection.MoveDown Unit:=wdParagraph, Count:=2, Extend:=wdExtend
    Selection.Fields.Unlink
    Selection.ConvertToTable Separator:=wdSeparateByTabs, NumColumns:=2, _
    NumRows:=20, Format:=wdTableFormatNone, ApplyBorders:=True, ApplyShading _
    :=True, ApplyFont:=True, ApplyColor:=True, ApplyHeadingRows:=True, _
    ApplyLastRow:=False, ApplyFirstColumn:=True, ApplyLastColumn:=False, _
    AutoFit:=True, AutoFitBehavior:=wdAutoFitContent
    Selection.MoveLeft Unit:=wdCharacter, Count:=1
    End Sub

  4. #4
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Opening a blank Doc. (Word XP)

    Hummm. I take that back, the code isn't much help at this point. A little, I guess.

    Here's some air code (heavy on the CO2) (see Rory, I like it so much I'm using it now!)
    Tell us if this is a correct interpretation of your intentions:

    1. Add a table of contents
    2. Select the table of contents using the find method
    3. Then copy that selected TOC to the clipboard
    4. Create new blank doc.
    5. Paste TOC from clipboard into new doc
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  5. #5
    3 Star Lounger
    Join Date
    Jul 2002
    Location
    Edison, New Jersey, USA
    Posts
    215
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Re: Opening a blank Doc. (Word XP)

    OOOPS! I posted the wrong code... I think it's similar, but this one at least has comments...


    Sub RTMCreate2()
    '
    ' RTMCreate2 Macro
    ' Macro recorded 4/15/2003 by Jody Dyche
    '
    'Go to beginning of document and go to beginning of TOC. Select TOC.
    Selection.HomeKey Unit:=wdStory
    Selection.Find.ClearFormatting
    Selection.Find.Style = ActiveDocument.Styles("TOC 1")
    Selection.Find.ParagraphFormat.Borders.Shadow = False
    With Selection.Find
    .Text = ""
    .Replacement.Text = ""
    .Forward = True
    .Wrap = wdFindContinue
    .Format = True
    .MatchCase = False
    .MatchWholeWord = False
    .MatchWildcards = False
    .MatchSoundsLike = False
    .MatchAllWordForms = False
    End With
    Selection.Find.Execute
    Selection.MoveDown Unit:=wdParagraph, Count:=1, Extend:=wdExtend

    'Replace Existing TOC with 9 level TOC
    With ActiveDocument
    .TablesOfContents(1).Delete
    .TablesOfContents.Add Range:=Selection.Range, RightAlignPageNumbers:= _
    True, UseHeadingStyles:=True, UpperHeadingLevel:=4, _
    LowerHeadingLevel:=9, IncludePageNumbers:=False, AddedStyles:= _
    "Heading 1,1,Heading 2,2,Heading 3,3", UseHyperlinks:=True, _
    HidePageNumbersInWeb:=True
    .TablesOfContents(1).TabLeader = wdTabLeaderDots
    .TablesOfContents.Format = wdIndexIndent
    End With

    'Go to beginning of document, Go to TOC, select and copy.
    Selection.HomeKey Unit:=wdStory
    Selection.Find.ClearFormatting
    Selection.Find.Style = ActiveDocument.Styles("TOC 1")
    Selection.Find.ParagraphFormat.Borders.Shadow = False
    With Selection.Find
    .Text = ""
    .Replacement.Text = ""
    .Forward = True
    .Wrap = wdFindContinue
    .Format = True
    .MatchCase = False
    .MatchWholeWord = False
    .MatchWildcards = False
    .MatchSoundsLike = False
    .MatchAllWordForms = False
    End With
    Selection.Find.Execute
    Selection.MoveDown Unit:=wdParagraph, Count:=1, Extend:=wdExtend
    Selection.Copy

    'Open New document and paste.
    Selection.Paste
    Selection.HomeKey Unit:=wdStory
    Selection.WholeStory
    Selection.Fields.Unlink
    Selection.ConvertToTable Separator:=wdSeparateByTabs, NumColumns:=2, _
    NumRows:=21, Format:=wdTableFormatNone, ApplyBorders:=True, ApplyShading _
    :=True, ApplyFont:=True, ApplyColor:=True, ApplyHeadingRows:=True, _
    ApplyLastRow:=False, ApplyFirstColumn:=True, ApplyLastColumn:=False, _
    AutoFit:=True, AutoFitBehavior:=wdAutoFitFixed
    Selection.HomeKey Unit:=wdLine
    Selection.MoveRight Unit:=wdCell
    Selection.HomeKey Unit:=wdLine
    Selection.HomeKey Unit:=wdStory
    End Sub

  6. #6
    3 Star Lounger
    Join Date
    Jul 2002
    Location
    Edison, New Jersey, USA
    Posts
    215
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Re: Opening a blank Doc. (Word XP)

    Yes... But I also want to manipulate it, once in the new doc.

  7. #7
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Opening a blank Doc. (Word XP)

    Meaning....?

    What do you want to do to the TOC in the new document?
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  8. #8
    3 Star Lounger
    Join Date
    Jul 2002
    Location
    Edison, New Jersey, USA
    Posts
    215
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Re: Opening a blank Doc. (Word XP)

    Select it, Break the link and convert it to a table.

    Though, that could be done in the current doc, cut and pasted into the new doc.

    Either way, when I open a new doc, the code for such doesn't record. It picks back up where I paste (supposedly into the new doc)... but it pastes right into the same doc.

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

    Re: Opening a blank Doc. (Word XP)

    Insert the instruction to create a new document after copying and before pasting:

    ...
    Selection.Copy

    'Open New document and paste.
    Documents.Add ' Creates a new doc and makes it the active doc.
    Selection.Paste
    ...

  10. #10
    3 Star Lounger
    Join Date
    Jul 2002
    Location
    Edison, New Jersey, USA
    Posts
    215
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Re: Opening a blank Doc. (Word XP)

    That's all it needed! Case Solved - Thank - You.

Posting Permissions

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