Consulting

Results 1 to 4 of 4

Thread: Solved: Determining the Active Cell...

  1. #1

    Solved: Determining the Active Cell...

    Hi guys!

    Well, I'm back!

    This time with a short snapper!

    About a year ago, a few contributors here made a wonderful macro for me that reads Word documents and row-by-row, spits out the bookmark values.

    Boy, do we love it!

    Now, there is one thing I would like to change, and being the absolute VBA n00b, I figured I'd ask the pros!

    By design, the macro prompts user for the beginning row in which to fill in the data (intRow), as well as the column (intCol).

    This means that the user always has to type two numbers before running this macro.

    I was wondering that instead of prompting the user for intRow and intCol, if there is a not a way to simply make intRow equal to the Row number of the current active cell, and intCol the Column number of the active cell.

    This way, the user need only put the cursor on the cell in which the bookmark shall start pasting!

    I hope this is possible!

    Thanks for your ideas!

    Here is where the variables are used!

    [vba]'Loop through all the fields
    For x = 1 To WordDoc.Bookmarks.Count

    'intRow is the file order number (each file will import on a new row)
    'the x is the column - Essentially it'll cycle through all the bookmarks
    'in the Word doc

    ActiveSheet.Cells(intRow + intFileNum, x + intCol - 1) = _
    WordDoc.FormFields(WordDoc.Bookmarks(x).Name).Result

    If Err.Number <> 0 Then
    Err.Clear
    ActiveSheet.Cells(intRow + intFileNum, x + intCol - 1) = _
    WordDoc.Bookmarks(x).Range.Text
    End If

    Next[/vba]

    Thanks so much!!!

    Mike

    Edited 10-Apr-06 by GeekGirlau. Reason: Insert line break in code
    Last edited by Michael 514; 04-10-2006 at 10:25 AM.

  2. #2
    Site Admin
    Jedi Master
    VBAX Guru Jacob Hilderbrand's Avatar
    Joined
    Jun 2004
    Location
    Roseville, CA
    Posts
    3,712
    Location
    Try this:

    [vba]
    ActiveSheet.Cells(ActiveCell.Row + intFileNum, x + ActiveCell.Column - 1)
    [/vba]

  3. #3
    WOOHOO!!!!!!!!!!!!!

    ActiveCell.Row and ActiveCell.Column!

    Love it!

    Thanks a million!!!!!!!

    Have a good one!

    Mike

  4. #4
    Site Admin
    Jedi Master
    VBAX Guru Jacob Hilderbrand's Avatar
    Joined
    Jun 2004
    Location
    Roseville, CA
    Posts
    3,712
    Location
    You're Welcome

    Take Care

Posting Permissions

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