Results 1 to 3 of 3
  1. #1
    Lounger
    Join Date
    Feb 2001
    Location
    Toronto, Ontario, Canada
    Posts
    44
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Variable in Excel 4 Macro (Excel 2000)

    Page Setup in VBA executes very slowly, so I am accepting Bullen/Bovey/Green suggestion to use the Page.Setup Excel4 macro. My problem is, I can't see how to use a variable in the Header.
    The code looks like this:
    ExecuteExcel4Macro "page.setup(""&LCheck Log for &D &RBatch # "",,,.25,.25,.5,.25,,true,false,false,2,1,85,,,,,, ,,)"
    This works, but what I want to do is include a variable after "Batch #". I can't seem to get any combination of quotes and ampersands to work. Am I simply SOL?
    Thanks

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

    Re: Variable in Excel 4 Macro (Excel 2000)

    As far as I can tell, you've got an extra comma between the header string and the margins. Try something like this:
    <code>
    Dim lngBatchNo As Long
    lngBatchNo = 37
    ExecuteExcel4Macro "page.setup(""&LCheck Log for &D &RBatch # " & _
    lngBatchNo & """,,.25,.25,.5,.25,,true,false,false,2,1,85)"
    </code>
    The variable lngBatchNo is concatenated into the header string.

  3. #3
    Lounger
    Join Date
    Feb 2001
    Location
    Toronto, Ontario, Canada
    Posts
    44
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Variable in Excel 4 Macro (Excel 2000)

    Hans,
    Brilliant, as usual. I guess I did not try all the combinations.
    Thank you ver much.

Posting Permissions

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