+ Reply to Thread
Results 1 to 5 of 5

how to reference a Excel worksheet with its codeName from word (2003) VBA?

  1. #1
    Registered User
    Join Date
    08-10-2012
    Location
    germany
    MS-Off Ver
    Excel 2003
    Posts
    34

    how to reference a Excel worksheet with its codeName from word (2003) VBA?

    HI guys,
    I have written some codes in word(2003) VBA which accesses a excel(2003) worksheet by referring the Worksheet tab names. The problem arises when the users rename the Worksheet tabs. I want the code to funtion independent of the name of the worksheet tabs. I know that can be done by using code names of the worksheets.But i dont know how to do it from word(2003) VBA.
    the sample codes are as shown below :

    Please Login or Register  to view this content.
    Can anyone help?

    Thanks in advance..
    Sam

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: how to reference a Excel worksheet with its codeName from word (2003) VBA?

    Sam

    You can't use the codename in Word VBA, you need code to find the worksheet with the codename you want.
    Please Login or Register  to view this content.

  3. #3
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: how to reference a Excel worksheet with its codeName from word (2003) VBA?

    You could use code like:
    oWB.Sheets(1).Range("R1").Value= 22
    However, if your users are going to start changing sheet names, what's to stop them changing the sheet order???

    Perhaps you should consider applying workbook protection to prevent such changes.
    Cheers,
    Paul Edstein
    [Fmr MS MVP - Word]

  4. #4
    Registered User
    Join Date
    08-10-2012
    Location
    germany
    MS-Off Ver
    Excel 2003
    Posts
    34

    Re: how to reference a Excel worksheet with its codeName from word (2003) VBA?

    Thanks a lot Norie, it worked..

  5. #5
    Registered User
    Join Date
    08-10-2012
    Location
    germany
    MS-Off Ver
    Excel 2003
    Posts
    34

    Re: how to reference a Excel worksheet with its codeName from word (2003) VBA?

    Thanks Paul Edstein for the suggestion..

+ 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