+ Reply to Thread
Results 1 to 4 of 4

Allow user select file to copy data from "Application.GetOpenFilen

  1. #1
    Rob Moore
    Guest

    Allow user select file to copy data from "Application.GetOpenFilen

    I have been working on a macro that will prompt the user to select a file and
    then copy and paste (special values) that entire worksheet into a new
    worksheet "old file". I have tried 'Application.GetOpenFilename' which
    prompts me to select the file to copy but that file never opens up. Any
    ideas.

    Thanks,
    Rob

  2. #2
    PY & Associates
    Guest

    Re: Allow user select file to copy data from "Application.GetOpenFilen

    'Application.GetOpenFilename' only gets the filename but does nothing. The
    second step is to

    workbooks.open filename:= #### to open it.

    "Rob Moore" <RobMoore@discussions.microsoft.com> wrote in message
    news:99528956-80B1-4518-99A5-6936269745D1@microsoft.com...
    > I have been working on a macro that will prompt the user to select a file

    and
    > then copy and paste (special values) that entire worksheet into a new
    > worksheet "old file". I have tried 'Application.GetOpenFilename' which
    > prompts me to select the file to copy but that file never opens up. Any
    > ideas.
    >
    > Thanks,
    > Rob




  3. #3
    Rowan
    Guest

    Re: Allow user select file to copy data from "Application.GetOpenFilen

    An example:

    Private Sub OpenFile()

    Dim flToOpen As Variant
    Dim fFilter As String

    fFilter = "Excel Files (*.xls), *.xls"
    flToOpen = Application.GetOpenFilename(fFilter)

    If flToOpen = False Then
    Exit Sub 'if user hits cancel then macro ends
    Else
    Workbooks.Open Filename:=flToOpen
    End If

    End Sub

    Hope this helps
    Rowan

    Rob Moore wrote:
    > I have been working on a macro that will prompt the user to select a file and
    > then copy and paste (special values) that entire worksheet into a new
    > worksheet "old file". I have tried 'Application.GetOpenFilename' which
    > prompts me to select the file to copy but that file never opens up. Any
    > ideas.
    >
    > Thanks,
    > Rob


  4. #4
    Mike Fogleman
    Guest

    Re: Allow user select file to copy data from "Application.GetOpenFilen

    'Application.GetOpenFilename' only gets the path to the file selected. It
    does not open it. This should be real close to what you want.

    Option Explicit
    Dim FileToOpen As String
    Dim MyBook As String
    Dim OldBook As String

    Sub CopyBookToBook()
    With Application
    .DisplayAlerts = False
    .ScreenUpdating = False
    End With

    MyBook = ActiveWorkbook.Name
    FileToOpen = Application _
    .GetOpenFilename("Excel Files (*.xls), *.xls")
    If FileToOpen = "False" Then
    Exit Sub
    End If
    Workbooks.Open (FileToOpen)
    OldBook = ActiveWorkbook.Name
    Worksheets("Sheet1").UsedRange.Copy
    Workbooks(MyBook).Worksheets("Old File").Range("A1").PasteSpecial (xlValues)
    Workbooks(OldBook).Close
    Range("A1").Select
    With Application
    .DisplayAlerts = True
    .ScreenUpdating = True
    End With
    End Sub


    Mike F

    "Rob Moore" <RobMoore@discussions.microsoft.com> wrote in message
    news:99528956-80B1-4518-99A5-6936269745D1@microsoft.com...
    >I have been working on a macro that will prompt the user to select a file
    >and
    > then copy and paste (special values) that entire worksheet into a new
    > worksheet "old file". I have tried 'Application.GetOpenFilename' which
    > prompts me to select the file to copy but that file never opens up. Any
    > ideas.
    >
    > Thanks,
    > Rob




+ 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