+ Reply to Thread
Results 1 to 2 of 2

Using Application.GetOpenFilename to replace links

  1. #1
    Registered User
    Join Date
    12-26-2021
    Location
    Swansea
    MS-Off Ver
    2019
    Posts
    14

    Using Application.GetOpenFilename to replace links

    Hi There.

    I have the following code which copies and pastes a range into a custom cell selected by the user.

    It then attempts to change the links in that copied range (Via the Application.GetOpenFilename) to a file specified by the user.

    It is however hitting a bug.

    Any insight as to how to fix this would be most appreciated.

    Thanks


    Please Login or Register  to view this content.
    Last edited by AndyT88; 04-03-2023 at 04:47 PM. Reason: changed code

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,090

    Re: Using Application.GetOpenFilename to replace links

    This link gives fairly comprehensive coverage of Application.GetOpenFilename.

    https://www.xelplus.com/excel-vba-getopenfilename/

    Sub Get_Data_From_File()
    Dim FileToOpen As Variant
    Dim OpenBook as Workbook
    FileToOpen = Application.GetOpenFilename(Title:="Browse for your File & Import Range", FileFilter:="Excel Files (*.xls*),*xls*")
    If FileToOpen <> False Then
    Set OpenBook = Application.Workbooks.Open(FileToOpen)
    OpenBook.Sheets(1).Range("A1:E20").Copy
    ThisWorkbook.Worksheets("SelectFile").Range("A10").PasteSpecial xlPasteValues
    OpenBook.Close False
    End If
    End Sub
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


+ 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. [SOLVED] Obscure VBA error? Application.Run conflicts with Application.GetOpenFileName
    By mc84excel in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 10-15-2013, 08:31 PM
  2. [SOLVED] I need help with Application.GetOpenFileName
    By venkatpvc in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-12-2013, 10:00 AM
  3. Application.GetOpenFilename
    By Screamtruth in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 06-06-2010, 02:49 PM
  4. [SOLVED] Application.GetOpenFileName
    By Chris in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-18-2006, 07:40 PM
  5. [SOLVED] Application.GetOpenFileName() question
    By JimP in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-14-2005, 06:10 AM
  6. [SOLVED] [SOLVED] Application.GetOpenFilename vs Application.Dialogs(xlDialogsOpen)
    By Paul Martin in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-05-2005, 12:05 PM
  7. [SOLVED] Application.GetOpenFilename
    By Nigel in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-23-2005, 12:06 PM
  8. Application.GetOpenFilename
    By Greg in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-19-2005, 10:06 PM

Tags for this Thread

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