+ Reply to Thread
Results 1 to 3 of 3

Thread: Prefix a Path Folder in Macro

  1. #1
    Registered User
    Join Date
    10-05-2011
    Location
    USA, Maryland
    MS-Off Ver
    Excel 2007
    Posts
    8

    Prefix a Path Folder in Macro

    Hi there,

    Need help again! Basically I have the code,

    If Range("E137").Value = "1" Then
        Range("A56:L73").Select
        Selection.Copy
        Workbooks.Open(Sheet2.TextBox1.Value).Activate
        Range("A56").Select
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
        End If

    A workbook will open when I activate this macro. In order for the workbook to be open, the user will need to type in the workbook file name and the folders it is stored in the ActiveX text box. E.g,

    The user will need to type in C:\Documents and Settings\Test\Desktop\Test Folder\Test File

    What I want is for the user to just type in the file name which is Test File. Note that the place where the file is stored is fixed. Is it possible?

    Please help, thanks!

    Using WinXP and Excel 2007.

  2. #2
    Valued Forum Contributor quekbc's Avatar
    Join Date
    01-18-2010
    Location
    Sydney, Australia
    MS-Off Ver
    2003, 2007, 2010
    Posts
    263

    Re: Prefix a Path Folder in Macro

    The parameter in Workbooks.Open is a string (text). Hence, you can do something like...

    Dim strPath as String
    strPath = "C:\Documents and Settings\Test\Desktop\Test Folder\" strPath = strPath & Sheet2.TextBox1.Value Workbooks.Open(strPath).Activate

  3. #3
    Registered User
    Join Date
    10-05-2011
    Location
    USA, Maryland
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: Prefix a Path Folder in Macro

    Quote Originally Posted by quekbc View Post
    The parameter in Workbooks.Open is a string (text). Hence, you can do something like...

    Dim strPath as String
    strPath = "C:\Documents and Settings\Test\Desktop\Test Folder\" strPath = strPath & Sheet2.TextBox1.Value Workbooks.Open(strPath).Activate
    It worked! Thanks alot!

+ 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.2.0