Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default How do i save a image to the same folder my .xls file is located?

I want to allow the user to tell me where a file(.pdf, .tif,.gif, .doc, etc)
is located. After that I want the progrem to verfy the file exist, then save
a new copy to the same path as my .xls docment and under a new name. Can you
Help?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default How do i save a image to the same folder my .xls file is located?

How about letting the user choose the file. Then you know that it exists.

Option Explicit
Sub testme()
Dim myFileName As Variant
Dim JustFileName As String
Dim NewPath As String

myFileName = Application.GetOpenFilename(filefilter:="All Files, *.*")

If myFileName = False Then
'user hit cancel
Exit Sub
End If

JustFileName = Mid(myFileName, InStrRev(myFileName, "\") + 1)

NewPath = ThisWorkbook.Path 'activeworkbook.path????

FileCopy Source:=myFileName, _
Destination:=NewPath & "\" & JustFileName

End Sub


Mr. GetRight wrote:

I want to allow the user to tell me where a file(.pdf, .tif,.gif, .doc, etc)
is located. After that I want the progrem to verfy the file exist, then save
a new copy to the same path as my .xls docment and under a new name. Can you
Help?


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default How do i save a image to the same folder my .xls file is locat

Works Perfectly! Thanks a Million!

"Dave Peterson" wrote:

How about letting the user choose the file. Then you know that it exists.

Option Explicit
Sub testme()
Dim myFileName As Variant
Dim JustFileName As String
Dim NewPath As String

myFileName = Application.GetOpenFilename(filefilter:="All Files, *.*")

If myFileName = False Then
'user hit cancel
Exit Sub
End If

JustFileName = Mid(myFileName, InStrRev(myFileName, "\") + 1)

NewPath = ThisWorkbook.Path 'activeworkbook.path????

FileCopy Source:=myFileName, _
Destination:=NewPath & "\" & JustFileName

End Sub


Mr. GetRight wrote:

I want to allow the user to tell me where a file(.pdf, .tif,.gif, .doc, etc)
is located. After that I want the progrem to verfy the file exist, then save
a new copy to the same path as my .xls docment and under a new name. Can you
Help?


--

Dave Peterson

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
Save file in a new folder, but create folder only if folder doesn't already exist? nbaj2k[_40_] Excel Programming 6 August 11th 06 08:41 PM
Need code to save file to new folder, erase from old folder Ron M. Excel Discussion (Misc queries) 1 February 24th 06 06:02 PM
open file from folder save in new folder tim64[_3_] Excel Programming 20 June 17th 05 07:58 PM
How to save a bar chart as an image file programmatically? Fool Excel Programming 1 August 2nd 04 01:35 PM
Save an image from a worksheet to a file barbral Excel Programming 1 August 15th 03 02:39 PM


All times are GMT +1. The time now is 02:12 AM.

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

About Us

"It's about Microsoft Excel"