+ Reply to Thread
Results 1 to 2 of 2

Variable problem

  1. #1
    Rob Hargreaves
    Guest

    Variable problem

    I am using automation to work with word and i would like to use the code I
    have to add bookmarks with a constant for the name then the page number
    following that.

    The code works for positioning perfectly when tested with an insertafter and
    add an "X" but gives me an error in my bookmark names.

    The code is like this -

    r.Bookmarks.Add "MeterNo & Selection.Information(wdActiveEndPageNumber)),
    vbInformation"

    I can use the same line of code in a messagebox and it works.

    This is the line used in the messagebox in word.

    MsgBox ("page no -" & Selection.Information(wdActiveEndPageNumber)),
    vbInformation

    I have tried to replace it like this

    r.Bookmarks.Add "MeterNo & mypage"

    and add the line

    mypage = Selection.Information(wdActiveEndPageNumber)

    and declare it as dim as variant and dim as string but neither approach
    works.

    can someone give me hand here

    Thanks

    Rob




  2. #2
    Gareth
    Guest

    Re: Variable problem

    You might want to try posting in the word.vba NG.

    Rob Hargreaves wrote:
    > I am using automation to work with word and i would like to use the code I
    > have to add bookmarks with a constant for the name then the page number
    > following that.
    >
    > The code works for positioning perfectly when tested with an insertafter and
    > add an "X" but gives me an error in my bookmark names.
    >
    > The code is like this -
    >
    > r.Bookmarks.Add "MeterNo & Selection.Information(wdActiveEndPageNumber)),
    > vbInformation"
    >
    > I can use the same line of code in a messagebox and it works.
    >
    > This is the line used in the messagebox in word.
    >
    > MsgBox ("page no -" & Selection.Information(wdActiveEndPageNumber)),
    > vbInformation
    >
    > I have tried to replace it like this
    >
    > r.Bookmarks.Add "MeterNo & mypage"
    >
    > and add the line
    >
    > mypage = Selection.Information(wdActiveEndPageNumber)
    >
    > and declare it as dim as variant and dim as string but neither approach
    > works.
    >
    > can someone give me hand here
    >
    > Thanks
    >
    > Rob
    >
    >
    >


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1