Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 145
Default 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" wrote in message
...
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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 88
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,092
Default 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" wrote in message
...
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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Selecting "Save As" adds "Copy of" to file name- MS Excel 2007 ronhansen Excel Discussion (Misc queries) 1 November 15th 09 09:33 PM
%1 appears in "Application used to perform action" when trying to edit a file type [email protected] Excel Worksheet Functions 3 December 7th 06 07:00 PM
Prompt user to select file with default file selected dialog Bruce Cooley Excel Programming 0 September 15th 03 06:43 AM
Prompt user to select file with default file selected dialog Bob Phillips[_5_] Excel Programming 0 September 14th 03 09:22 PM
Prompt user to select file with default file selected dialog Bob Phillips[_5_] Excel Programming 0 September 14th 03 09:19 PM


All times are GMT +1. The time now is 06:34 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"