Results 1 to 8 of 8
  1. #1
    2 Star Lounger
    Join Date
    Apr 2001
    Location
    Melbourne, Australia
    Posts
    118
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Logo and the top of the first page only (Visual Basic)

    Hi Guru's

    I have a template that has a company logo along the top and we have setup a macro
    that when you run it will display the company logo along the top of the page. However when you insert a
    page break it puts the logo at the top of the second page.
    Is there any command that you can enter that will along allow the logo to be displayed on the first page?

    Thanks and I hope that the above question makes sense.

    Kerrie<img src=/S/smile.gif border=0 alt=smile width=15 height=15>

  2. #2
    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: Logo and the top of the first page only (Visual Basic)

    Can I assume the logo is in the header and that's why it appears at the top of both pages? You probably want it to be only the first page header. Since this is a custom template, it probably makes sense to set it up with a different first page and insert the header in advance. Surely easier than using the macro, no?

    (If it's not in the header, please explain what's happening in more detail.)

  3. #3
    2 Star Lounger
    Join Date
    Apr 2001
    Location
    Melbourne, Australia
    Posts
    118
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Logo and the top of the first page only (Visual Basic)

    Not the logo is not in the header, it is inserted as an object.

    Below is a some of the code I have copied from the macro. Does this help?

    Public Sub MAIN()
    Dim To_$
    Dim To2$
    Dim To3$
    Dim To4$
    Dim co$
    Dim fax$
    Dim cc$
    Dim cc2$
    Dim cc3$
    Dim cc4$
    Dim from$
    Dim pgs$
    Dim subject$
    WordBasic.FileNew Template:="Simp_fax", NewTemplate:=0
    WordBasic.FilePageSetup Tab:="0", PaperSize:="0", TopMargin:="3.25 cm", BottomMargin:="1.5 cm", LeftMargin:="2 cm", RightMargin:="4.2 cm", Gutter:="0 cm", PageWidth:="21 cm", PageHeight:="29.7 cm", Orientation:=0, FirstPage:=0, OtherPages:=0, VertAlign:=0, ApplyPropsTo:=4, FacingPages:=0, HeaderDistance:="0 cm", FooterDistance:="1 cm", SectionStart:=2, OddAndEvenPages:=0, DifferentFirstPage:=0, Endnotes:=0, LineNum:=0, StartingNum:="", FromText:="", CountBy:="0", NumMode:=-1
    WordBasic.ViewHeader
    WordBasic.GoToHeaderFooter
    WordBasic.FormatBordersAndShading ApplyTo:=0, Shadow:=0, TopBorder:=1, LeftBorder:=0, BottomBorder:=0, RightBorder:=0, HorizBorder:=0, VertBorder:=0, TopColor:=0, LeftColor:=0, BottomColor:=0, RightColor:=0, HorizColor:=0, VertColor:=0, FromText:="1 pt", Shading:=0, Foreground:=0, Background:=0, Tab:="0", FineShading:=-1
    WordBasic.FontSize 8
    WordBasic.InsertField Field:="FILENAME * Upperp * MERGEFORMAT"
    WordBasic.Insert Chr(9) + Chr(9) + "PAGE: "
    WordBasic.InsertPageField
    WordBasic.EditSelectAll
    WordBasic.FontSize 8
    WordBasic.FormatParagraph RightIndent:="-0.5 cm"
    WordBasic.CloseViewHeaderFooter
    WordBasic.VLine -12
    WordBasic.FormatParagraph LeftIndent:="0 cm", RightIndent:="0 cm", Before:="0 pt", After:="0 pt", LineSpacingRule:=0, LineSpacing:="", Alignment:=2, WidowControl:=1, KeepWithNext:=0, KeepTogether:=0, PageBreak:=0, NoLineNum:=0, DontHyphen:=0, Tab:="0", FirstIndent:="0 cm"
    WordBasic.FormatParagraph RightIndent:="-0.96 cm"
    WordBasic.FontSize 8
    WordBasic.Font "Arial"


    Thanks Kindly,

    Kerrie<img src=/S/smile.gif border=0 alt=smile width=15 height=15>

  4. #4
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Brisbane, Australia
    Posts
    245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Logo and the top of the first page only (Visual Basic)

    You might consider this, Kerrie, as a simple solution without the need for code.

    I did a similar thing for a client with their FAX.

    I created the template (single page) with the logo in the header. I then set up the headers to be different first page. (File | Page Setup | Layout tab | Different first page option).

    Then I added a second page and made sure that the logo was not showing by first checking that the two headers were not linked. (View | Header and Footer and making sure that 'Same as previous' was greyed out.).

    Then I removed the second page and tried it out. MS Word had retained the information about the first page header even though there was only one page in the Fax template. And the logo appeared only once on the first page. I also set up different sizes for the two headers which was remembered in the one page Fax template, thankfully!

    HTH, Leigh

  5. #5
    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: Logo and the top of the first page only (Visual Basic)

    I tried to run your code, but the secret must be in your template. <img src=/S/smile.gif border=0 alt=smile width=15 height=15>

    It could be something to do with the way the object is inserted into the document. For example, it may be placed in relation to the final paragraph (which starts off as the initial paragraph, but keeps getting pushed down, so it will always appear on the last page regardless of the number of pages in the document. If that is the problem, you might insert an extra paragraph and anchor it to that one, and perhaps add a note to your users in hidden text not to move or delete that line/paragraph.

    If that isn't it, please post a sample document created with this template and macro, and the object gurus can take a shot.

  6. #6
    2 Star Lounger
    Join Date
    Apr 2001
    Location
    Melbourne, Australia
    Posts
    118
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Logo and the top of the first page only (Visual Basic)

    Thank you for your help, I tried attaching the file and it encountered an error, <img src=/S/smile.gif border=0 alt=smile width=15 height=15>

    The logo is now in the letterhead, however when you add a page the logo appears on the second page.
    I know if you add a section break you can set it up so that it will only appear on the first page, but how do I
    write it into the VB code for the template? Below is the code for the macro.
    Will this assist?

    Public Sub MAIN()
    Dim To_$
    Dim To2$
    Dim To3$
    Dim To4$
    Dim fax$
    Dim fax2$
    Dim fax3$
    Dim fax4$
    Dim cc$
    Dim cc2$
    Dim cc3$
    Dim cc4$
    Dim from$
    Dim pgs$
    Dim subject$
    WordBasic.FileNew Template:="Simp_fax", NewTemplate:=0
    WordBasic.FilePageSetup Tab:="0", PaperSize:="0", TopMargin:="3.25 cm", BottomMargin:="1.5 cm", LeftMargin:="2 cm", RightMargin:="4.2 cm", Gutter:="0 cm", PageWidth:="21 cm", PageHeight:="29.7 cm", Orientation:=0, FirstPage:=0, OtherPages:=0, VertAlign:=0, ApplyPropsTo:=4, FacingPages:=0, HeaderDistance:="0 cm", FooterDistance:="1 cm", SectionStart:=2, OddAndEvenPages:=0, DifferentFirstPage:=0, Endnotes:=0, LineNum:=0, StartingNum:="", FromText:="", CountBy:="0", NumMode:=-1
    ' WordBasic.ViewHeader
    ' WordBasic.GoToHeaderFooter
    ' WordBasic.FormatBordersAndShading ApplyTo:=0, Shadow:=0, TopBorder:=1, LeftBorder:=0, BottomBorder:=0, RightBorder:=0, HorizBorder:=0, VertBorder:=0, TopColor:=0, LeftColor:=0, BottomColor:=0, RightColor:=0, HorizColor:=0, VertColor:=0, FromText:="1 pt", Shading:=0, Foreground:=0, Background:=0, Tab:="0", FineShading:=-1
    ' WordBasic.FontSize 8
    ' WordBasic.InsertField Field:="FILENAME * Upperp * MERGEFORMAT"
    ' WordBasic.Insert Chr(9) + Chr(9) + "PAGE: "
    ' WordBasic.InsertPageField
    ' WordBasic.EditSelectAll
    ' WordBasic.FontSize 8
    ' WordBasic.FormatParagraph RightIndent:="-0.5 cm"
    ' WordBasic.CloseViewHeaderFooter
    WordBasic.VLine -12
    WordBasic.FormatParagraph LeftIndent:="0 cm", RightIndent:="0 cm", Before:="0 pt", After:="0 pt", LineSpacingRule:=0, LineSpacing:="", Alignment:=2, WidowControl:=1, KeepWithNext:=0, KeepTogether:=0, PageBreak:=0, NoLineNum:=0, DontHyphen:=0, Tab:="0", FirstIndent:="0 cm"
    WordBasic.FormatParagraph RightIndent:="-0.96 cm"
    WordBasic.FontSize 8
    WordBasic.Font "Arial"
    WordBasic.Insert "Information Services"
    WordBasic.InsertPara
    WordBasic.Insert "Fax: (03) 9588 4451"
    WordBasic.InsertPara
    WordBasic.LineDown 1
    WordBasic.ResetPara

    WordBasic.TableInsertTable ConvertFrom:="", NumColumns:="4", NumRows:="9", InitialColWidth:="Auto", Format:="0", Apply:="167"
    WordBasic.TableSelectTable
    WordBasic.FontSize 12
    WordBasic.CharLeft 1
    WordBasic.TableSelectColumn
    WordBasic.TableColumnWidth ColumnWidth:="2.6 cm", SpaceBetweenCols:="0.38 cm", RulerStyle:="0"
    WordBasic.CharRight 1
    WordBasic.TableSelectColumn
    WordBasic.TableColumnWidth ColumnWidth:="4.5 cm", SpaceBetweenCols:="0.38 cm", RulerStyle:="0"
    WordBasic.CharRight 1
    WordBasic.TableColumnWidth ColumnWidth:="4.5 cm", SpaceBetweenCols:="0.38 cm", RulerStyle:="0"
    WordBasic.CharRight 1
    WordBasic.TableColumnWidth ColumnWidth:="4.5 cm", SpaceBetweenCols:="0.38 cm", RulerStyle:="0"
    WordBasic.LineDown 8
    WordBasic.CharLeft 2
    WordBasic.WordRight 3, 1
    WordBasic.TableMergeCells
    WordBasic.CharLeft 1
    WordBasic.EndOfLine
    WordBasic.WW6_EditClear
    WordBasic.LineUp 8
    WordBasic.CharLeft 1


    WordBasic.Bold
    WordBasic.Insert "TO:"
    WordBasic.Bold
    WordBasic.CharRight 1
    To_$ = WordBasic.[InputBox$]("Please enter the recipient of the fax")
    To_$ = UCase(To_$)
    WordBasic.Insert To_$

    more1:
    To2$ = WordBasic.[InputBox$]("Please enter the next recipient of the fax. If none, leave blank")
    If To2$ = "" Then
    GoTo more2
    Else
    WordBasic.CharRight 1
    To2$ = UCase(To2$)
    WordBasic.Insert To2$
    End If

    To3$ = WordBasic.[InputBox$]("Please enter the next recipient of the fax. If none, leave blank")
    If To3$ = "" Then
    GoTo more2
    Else
    WordBasic.CharRight 1
    To3$ = UCase(To3$)
    WordBasic.Insert To3$
    End If

    To4$ = WordBasic.[InputBox$]("Please enter the next recipient of the fax. If none, leave blank")
    If To4$ = "" Then
    GoTo more2
    Else
    WordBasic.LineDown 1
    WordBasic.TableInsertRow NumRows:=""
    WordBasic.LineUp 1
    WordBasic.LineDown 1
    WordBasic.CharRight 1
    To4$ = UCase(To4$)
    WordBasic.Insert To4$
    GoTo more1
    End If

    more2:
    WordBasic.WW7_EditGoTo Destination:="l"
    WordBasic.LineDown 1
    WordBasic.Bold
    WordBasic.Insert "FAX NO:"
    WordBasic.Bold
    WordBasic.CharRight 1
    fax$ = WordBasic.[InputBox$]("Please enter the fax number of the fax receiver")
    WordBasic.Insert fax$

    more3:
    fax2$ = WordBasic.[InputBox$]("Please enter the next fax number of the fax receiver. If none, leave blank")
    If fax2$ = "" Then
    GoTo more4
    Else
    WordBasic.CharRight 1
    WordBasic.Insert fax2$
    End If

    fax3$ = WordBasic.[InputBox$]("Please enter the next fax number of the fax receiver. If none, leave blank")
    If fax3$ = "" Then
    GoTo more4
    Else
    WordBasic.CharRight 1
    WordBasic.Insert fax3$
    End If

    fax4$ = WordBasic.[InputBox$]("Please enter the next fax number of the fax receiver. If none, leave blank")
    If fax4$ = "" Then
    GoTo more4
    Else
    WordBasic.LineDown 1
    WordBasic.TableInsertRow NumRows:=""
    WordBasic.LineUp 1
    WordBasic.LineDown 1
    WordBasic.CharRight 1
    WordBasic.Insert fax4$
    GoTo more3
    End If


    more4:
    cc$ = WordBasic.[InputBox$]("Please enter the carbon copy recipient of the fax. If none, leave blank.")
    If cc$ = "" Then
    GoTo more6
    Else
    WordBasic.WW7_EditGoTo Destination:="l"
    WordBasic.LineDown 1
    WordBasic.LineDown 1
    WordBasic.TableInsertRow NumRows:="2"
    WordBasic.LineUp 1
    WordBasic.Bold
    WordBasic.Insert "CC:"
    WordBasic.Bold
    WordBasic.CharRight 1
    WordBasic.Insert cc$
    WordBasic.StartOfLine 1
    WordBasic.FormatChangeCase Type:=3
    WordBasic.CharRight 1
    End If

    more5:
    cc2$ = WordBasic.[InputBox$]("Please enter the next carbon copy recipient of the fax. If none, leave blank")
    If cc2$ = "" Then
    GoTo more6
    Else
    WordBasic.CharRight 1
    WordBasic.Insert cc2$
    WordBasic.StartOfLine 1
    WordBasic.FormatChangeCase Type:=3
    WordBasic.CharRight 1
    End If

    cc3$ = WordBasic.[InputBox$]("Please enter the next carbon copy recipient of the fax. If none, leave blank")
    If cc3$ = "" Then
    GoTo more6
    Else
    WordBasic.CharRight 1
    WordBasic.Insert cc3$
    WordBasic.StartOfLine 1
    WordBasic.FormatChangeCase Type:=3
    WordBasic.CharRight 1
    End If

    cc4$ = WordBasic.[InputBox$]("Please enter the next carbon copy recipient of the fax. If none, leave blank")
    If cc4$ = "" Then
    GoTo more6
    WordBasic.WW7_EditGoTo Destination:="l"
    WordBasic.LineDown 1
    Else
    WordBasic.LineDown 1
    WordBasic.TableInsertRow NumRows:=""
    WordBasic.LineUp 1
    WordBasic.LineDown 1
    WordBasic.CharRight 1
    WordBasic.Insert cc4$
    WordBasic.StartOfLine 1
    WordBasic.FormatChangeCase Type:=3
    WordBasic.CharRight 1
    GoTo more5
    End If

    more6:
    WordBasic.WW7_EditGoTo Destination:="l"
    WordBasic.LineDown 1
    WordBasic.Bold
    WordBasic.Insert "FROM:"
    WordBasic.Bold
    WordBasic.CharRight 1
    WordBasic.WordRight 3, 1
    WordBasic.TableMergeCells
    WordBasic.CharLeft 1
    WordBasic.EndOfLine
    WordBasic.WW6_EditClear
    Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:= _
    "USERNAME * Upper", PreserveFormatting:=True
    Rem from$ = WordBasic.[InputBox$]("Please enter the sender of the fax")
    Rem from$ = UCase(from$)
    Rem WordBasic.Insert from$

    Selection.MoveDown Unit:=wdLine, Count:=2
    Selection.HomeKey Unit:=wdRow
    WordBasic.Bold
    WordBasic.Insert "DATE:"
    WordBasic.Bold
    WordBasic.CharRight 1
    WordBasic.AllCaps
    WordBasic.InsertDateTime DateTimePic:="d MMMM, yyyy", InsertAsField:=0

    WordBasic.CharRight 1
    WordBasic.WordRight 2, 1
    WordBasic.TableMergeCells
    WordBasic.CharLeft 1
    WordBasic.EndOfLine
    WordBasic.WW6_EditClear
    WordBasic.Bold
    WordBasic.RightPara
    WordBasic.Insert "NO OF PAGES:"
    WordBasic.Bold
    WordBasic.Insert " "
    pgs$ = WordBasic.[InputBox$]("Please enter the number of pages")
    WordBasic.Insert pgs$
    WordBasic.RightPara

    WordBasic.WW7_EditGoTo Destination:="l"
    WordBasic.LineDown 1
    WordBasic.Bold
    WordBasic.Insert "SUBJECT:"
    WordBasic.Bold
    WordBasic.CharRight 1
    subject$ = WordBasic.[InputBox$]("Please enter the subject of the fax")
    subject$ = UCase(subject$)
    WordBasic.Bold
    WordBasic.Insert subject$
    WordBasic.Bold

    WordBasic.LineDown 2
    WordBasic.InsertPara
    WordBasic.LineUp 1
    WordBasic.BorderLineStyle 1
    WordBasic.BorderBottom 1
    WordBasic.FormatParagraph RightIndent:="-0.65 cm"
    WordBasic.VLine 34
    WordBasic.LineDown 1
    WordBasic.FontSize 9
    WordBasic.JustifyPara
    WordBasic.Bold
    WordBasic.Insert "IMPORTANT:"
    WordBasic.Bold
    WordBasic.Insert " Information contained in this facsimile transmission (including any attachments) is confidential and is intended only for the use of the addressee. Any unauthorised use of this document or its contents is prohibited. If you receive this document in e" + "rror, please notify us immediately by telephone and destroy the original matter. Thank you."
    WordBasic.FormatBordersAndShading ApplyTo:=0, Shadow:=0, TopBorder:=0, LeftBorder:=0, BottomBorder:=1, RightBorder:=0, HorizBorder:=0, VertBorder:=0, TopColor:=0, LeftColor:=0, BottomColor:=0, RightColor:=0, HorizColor:=0, VertColor:=0, FromText:="2 pt", Shading:=0, Foreground:=0, Background:=0, Tab:="0", FineShading:=-1
    WordBasic.FormatParagraph RightIndent:="-0.65 cm"

    WordBasic.LineDown 1
    WordBasic.InsertPara
    WordBasic.ResetPara
    WordBasic.FontSize 12
    WordBasic.JustifyPara

    WordBasic.InsertPara
    WordBasic.InsertPara
    WordBasic.InsertPara
    WordBasic.Insert "Regards"
    WordBasic.InsertPara
    WordBasic.InsertPara
    WordBasic.InsertPara
    WordBasic.InsertPara
    WordBasic.InsertPara
    WordBasic.InsertPara
    WordBasic.Bold
    Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:= _
    "USERNAME * Upper", PreserveFormatting:=True
    Rem WordBasic.Insert from$
    WordBasic.Bold
    WordBasic.LineUp 8


    End Sub

    Private Sub Rest()
    End Sub

  7. #7
    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: Logo and the top of the first page only (Visual Basic)

    You should not need to use a section break if the Logo object is in the "First Page Header" rather than "Header". If it is in the First Page Header and is repeating itself in the Header, then go into the Header and press Alt-F9 to see if there are any field codes, such as REF that might be duplicating the object there.

  8. #8
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: Logo and the top of the first page only (Visual Basic)

    Kerrie,

    Seems like you would really be best off recreating this fax from scratch, following Jeff and Leigh's suggestions.

    I came to Word after WordBasic so don't really read it, but it looks like the code is doing all of the page setup and document layout programatically, which is kind of overkill* - better to just do the page setup and layout once manually and save that as the template. Far as I can tell, this code doesn't appear to be worth saving! <g>

    (* There are situations where it makes sense to have some setup properties done via code, for example if your firm had some offices that use Letter paper and some that use A4, but that sort of thing doesn't seem to apply here.)

    There are also about 15 InputBox statements that are asking the user for information - do you get 15 input boxes in succession pop up on your screen whenever you create a new document based on this template? - if so, that's got to get old very quickly. The better way to do this is to have a userform (custom dialog box) which pops up when you create a new document - the user can fill out all of the required information at one go.
    It's not that hard to create one of these...

    Gary

Posting Permissions

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