+ Reply to Thread
Results 1 to 3 of 3

when to use file extension and when not

  1. #1
    Forum Contributor
    Join Date
    04-09-2013
    Location
    City, World
    MS-Off Ver
    Office 365
    Posts
    248

    when to use file extension and when not

    Hello, I opened a new file and typed these 2 macros. The first one works the second one the second line does not. It seems I can not use Workbooks("book2")
    However; if I change the second line to

    Please Login or Register  to view this content.
    The main file I opened is not saved yet. Does that mean if a file saved then I have to use file extension when I call it, for example books2.xlsx ? and if the file is not saved yet, I can call it using the file name without extension, for example book1 ?

    Please Login or Register  to view this content.

  2. #2
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    365 Pro Plus
    Posts
    2,274

    Re: when to use file extension and when not

    Does that mean if a file saved then I have to use file extension when I call it, for example books2.xlsx ? and if the file is not saved yet, I can call it using the file name without extension, for example book1 ?
    Sounds right. The way around this is to assign the workbook to a variable when it's created. Something like:
    Please Login or Register  to view this content.

  3. #3
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,256

    Re: when to use file extension and when not

    Yes, you should always use the file extension (if there is one) with the Workbooks property.
    Remember what the dormouse said
    Feed your head

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 5
    Last Post: 12-29-2022, 06:35 AM
  2. Replies: 8
    Last Post: 12-23-2022, 04:09 AM
  3. Replies: 5
    Last Post: 12-23-2022, 04:04 AM
  4. Replies: 5
    Last Post: 12-23-2022, 04:02 AM
  5. Macro to open a list of spreadsheet and save them under file extension xlsx file
    By gdclyde in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-17-2017, 07:16 PM
  6. Replies: 4
    Last Post: 10-23-2013, 12:54 AM
  7. Replies: 4
    Last Post: 10-24-2008, 11:49 AM

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