+ Reply to Thread
Results 1 to 5 of 5

VBA, opening files.

  1. #1
    Registered User
    Join Date
    05-05-2020
    Location
    Norwich, England
    MS-Off Ver
    Office 365 / 2016
    Posts
    2

    VBA, opening files.

    Hello all.
    I'm relatively new to VBA, and learning how to use it has been very useful. I am currently stuck on something, the below code shows what I have so far.

    I can use this piece of code to find out the path of my workbook:
    Path = Application.ActiveWorkbook.Path


    And this piece of code opens a file with a .LOG extension from a pre-determined file path(same filepath as the workbook), copies the sheet, pastes it into my workbook and loops. This works well.

    Please Login or Register  to view this content.
    Moderator's note: Please take the time to review our rules. There aren't many, and they are all important. Rule #2 requires code tags. I have added them for you this time because you are a new member. --6StringJazzer

    I need to combine the two so I don't have to manually type in/copy paste the file path. Any help would be massively appreciated.

    Thanks
    Last edited by 6StringJazzer; 05-05-2020 at 10:33 AM.

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: VBA, opening files.

    This seems obvious to me so maybe I don't understand the question:

    Please Login or Register  to view this content.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: VBA, opening files.


    Hi !

    To 6StringJazzer : works only if you do not forget to add the path separator at the end of the workbook path !

  4. #4
    Registered User
    Join Date
    05-05-2020
    Location
    Norwich, England
    MS-Off Ver
    Office 365 / 2016
    Posts
    2

    Re: VBA, opening files.

    Hi,

    I had been using "Activeworkbook.Path" with no success. I then researched the ways of implementing the path separator.

    I have come up with this :Path = ActiveWorkbook.Path & Application.PathSeparator
    And it works!

    Thanks for your guidance (Y)

  5. #5
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: VBA, opening files.

    Quote Originally Posted by asaunders123 View Post
    I had been using "Activeworkbook.Path" with no success. I then researched the ways of implementing the path separator.

    I have come up with this :Path = ActiveWorkbook.Path & Application.PathSeparator
    And it works!

    Thanks for your guidance (Y)
    Glad to help and sorry that I did not give the correct answer. On a Windows machine you can just use

    ActiveWorkbook.Path & "\"

    but the code you came up with will run on both Windows and MacOS.

+ 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. Opening files in Excel 2013 from a folder without opening Excel first
    By Percy47746 in forum Hello..Introduce yourself
    Replies: 2
    Last Post: 01-10-2015, 07:28 AM
  2. Replies: 4
    Last Post: 12-04-2014, 12:14 PM
  3. [SOLVED] array calculation from 2 files without opening files
    By kevincoxshall in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-02-2014, 03:28 PM
  4. Saving as pdf files from opening an excel files
    By djfscouse in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-29-2013, 12:38 AM
  5. Opening files macro help (forcing directory, opening a tsv file)
    By NukedWhale in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-10-2010, 03:07 PM
  6. Opening data files within zip files automatically
    By HandL in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-09-2008, 10:48 AM
  7. [SOLVED] How can I view files chronologically when opening multiple files
    By Stevilsize in forum Excel General
    Replies: 3
    Last Post: 07-25-2005, 08:05 PM

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