Results 1 to 3 of 3

Thread: converting Word macro to VB[RESOVLED]

  1. #1

    Thread Starter
    Member
    Join Date
    Feb 2004
    Posts
    37

    converting Word macro to VB[RESOVLED]

    I have this macro from word i would like to use in VB, but there are a few things that i cant get to work.. first you see the macro as it looked in Word..

    If ActiveWindow.View.SplitSpecial <> wdPaneNone Then
    ActiveWindow.Panes(2).Close
    End If
    If ActiveWindow.ActivePane.View.Type = wdNormalView Or ActiveWindow. _
    ActivePane.View.Type = wdOutlineView Then
    ActiveWindow.ActivePane.View.Type = wdPrintView
    End If
    ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
    If Selection.HeaderFooter.IsHeader = True Then
    ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageFooter
    Else
    ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
    End If
    NormalTemplate.AutoTextEntries("Side X af Y").Insert Where:=Selection. _
    Range, RichText:=True
    ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument


    and this is what i would think it should look like in VB..

    If wrdDoc.ActiveWindow.View.SplitSpecial <> wdPaneNone Then
    ActiveWindow.Panes(2).Close
    End If
    If wrdDoc.ActiveWindow.ActivePane.View.Type = wdNormalView Or ActiveWindow. _
    ActivePane.View.Type = wdOutlineView Then
    ActiveWindow.ActivePane.View.Type = wdPrintView
    End If
    wrdDoc.ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
    If wrdDoc.Selection.HeaderFooter.IsHeader = True Then
    wrdDoc.ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageFooter
    Else
    wrdDoc.ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
    End If
    wrdDoc.NormalTemplate.AutoTextEntries("Side X af Y").Insert Where:=Selection. _
    Range, RichText:=True

    wrdDoc.ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument

    the blue lines is where it fails..

    what the macro is doing is Page numbers with one of the autotext formats.

    Anyone know what the problem might be ?

    Best regards

    Garnet
    Last edited by Garn; May 28th, 2004 at 05:35 AM.

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974
    On both of those lines I think you need the Application object rather than the Document object.


    Try replacing wrdDoc with the object you have for the application (maybe wrdApp.?), or wrdDoc.Application


    However, this section of your code (with my comments):
    VB Code:
    1. 'select header
    2. wrdDoc.ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
    3. If wrdDoc.Selection.HeaderFooter.IsHeader = True Then
    4.   'if header is selected [which it is!], select footer
    5.   wrdDoc.ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageFooter
    6. Else
    7.   '.. else select header [should never happen]
    8.   wrdDoc.ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
    9. End If
    could be replaced with this for the same effect:
    VB Code:
    1. 'select the footer
    2. wrdDoc.ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageFooter

  3. #3

    Thread Starter
    Member
    Join Date
    Feb 2004
    Posts
    37
    cheers m8 its working.. thanks

Posting Permissions

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



Click Here to Expand Forum to Full Width