* don't work with Workbook.open
Build custom Ribbon tabs in Excel
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 2 of 2

Thread: * don't work with Workbook.open

  1. #1
    Board Regular
    Join Date
    Jan 2015
    Post Thanks / Like
    0 Post(s)
    0 Thread(s)

    Default * don't work with Workbook.open


    I want to open the file starting with "Sales Records", and used the below code,

    But I get the error message that Excel can't find
    ...Sales Records*.xlsx

    Seems like Excel doesn't see * as wildcard in the below code but as part of the filename. Thank you.

    Dim Fname As String

    Dim WB1 As Workbook

    Application.ScreenUpdating = False

    Fname = ThisWorkbook.Name

    Set WB1 = Workbooks(Fname)

    Workbooks.Open Filename:=WB1.Path & "" & "Sales Records*.xlsx"

    Last edited by Apple1; Nov 19th, 2017 at 07:08 AM.

  2. #2
    Board Regular Ruddles's Avatar
    Join Date
    Aug 2010
    Glevum Castra, Britannia
    Post Thanks / Like
    0 Post(s)
    0 Thread(s)

    Default Re: * don't work with Workbook.open

    As far as I'm aware you can't use a wildcard with Workbooks.Open. You'd have to do something like this:-
    sFilename=Dir(WB1.Path & "" & "Sales Records*.xlsx")
    Workbooks.Open Filename:=sFilename
    On two occasions I have been asked, 'Pray, Mr Babbage, if you put into the machine wrong figures, will the right answers come out?'
    I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question.

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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