+ Reply to Thread
Results 1 to 4 of 4

open a file in VBA

Hybrid View

Zygoid open a file in VBA 12-10-2008, 09:48 AM
royUK Try Workbooks.Open... 12-10-2008, 09:53 AM
Zygoid Thanks Roy, rated the answer,... 12-10-2008, 10:03 AM
royUK Thanks for the rating How... 12-10-2008, 10:21 AM
  1. #1
    Registered User
    Join Date
    09-24-2003
    Posts
    62

    open a file in VBA

    I have a userform (userform1.Mulitpage1("page1")) with multiple checkboxes
    when clicking a commandbutton I want to open a file.

    I am getting an error message that the file cannot be found.

    the problem must be in the Dim or workbooks.open, the sCap1= does result in the correct file name.

    can anyone help?


    Dim sCap1 As String
    
    sCap1 = userform1.MultiPage1("Page1").CheckBox1.Caption & ".xls"
    
    Msgbox sCap1 << is to test the above to make sure the filename is correct.
    
    Workbooks.Open Filename:="C:\Database\sCap1"

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Try

    Workbooks.Open Filename:="C:\Database\" & sCap1
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Registered User
    Join Date
    09-24-2003
    Posts
    62
    Thanks Roy, rated the answer, but not sure how to mark post as solved.

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Thanks for the rating

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save

+ 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