Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 386
Default Save As Macro

Hi,


I would like to put a button into a worksheet which will take the current
file and resave it into the users My Documents under the name of Tester. So
the file will always have the same name and be saved in the My Docs of
whoever is using the file.

This piece of the code is part of a larger code which will remove VBA,
formulas etc to make a smaller file.

Thanks
LiAD
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Save As Macro

Copied from your previous query on how to get MyDocuments folder..

In a new module paste the below API function and then within a macro call
Msgbox SpecFolder(CSIDL_PERSONAL)


Public Declare Function SHGetSpecialFolderLocation Lib "shell32" (ByVal hWnd
As Long, ByVal nFolder As Long, ppidl As Long) As Long
Public Declare Function SHGetPathFromIDList Lib "shell32" Alias
"SHGetPathFromIDListA" (ByVal Pidl As Long, ByVal pszPath As String) As Long
Public Declare Sub CoTaskMemFree Lib "ole32" (ByVal pvoid As Long)
Public Const CSIDL_PERSONAL = &H5
Public Const CSIDL_DESKTOPDIRECTORY = &H10
Public Const MAX_PATH = 260
Public Const NOERROR = 0

Public Function SpecFolder(ByVal lngFolder As Long) As String
Dim lngPidlFound As Long
Dim lngFolderFound As Long
Dim lngPidl As Long
Dim strPath As String

strPath = Space(MAX_PATH)
lngPidlFound = SHGetSpecialFolderLocation(0, lngFolder, lngPidl)
If lngPidlFound = NOERROR Then
lngFolderFound = SHGetPathFromIDList(lngPidl, strPath)
If lngFolderFound Then
SpecFolder = Left$(strPath, InStr(1, strPath, vbNullChar) - 1)
End If
End If
CoTaskMemFree lngPidl
End Function

--
If this post helps click Yes
---------------
Jacob Skaria


"LiAD" wrote:

Hi,


I would like to put a button into a worksheet which will take the current
file and resave it into the users My Documents under the name of Tester. So
the file will always have the same name and be saved in the My Docs of
whoever is using the file.

This piece of the code is part of a larger code which will remove VBA,
formulas etc to make a smaller file.

Thanks
LiAD

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Save As Macro

User = Environ("UserProfile")
Folder = User & "\" & "Documents"
FName = Folder & "\" & ThisWorkbook.Name
ThisWorkbook.SaveAs Filename:=FName


"LiAD" wrote:

Hi,


I would like to put a button into a worksheet which will take the current
file and resave it into the users My Documents under the name of Tester. So
the file will always have the same name and be saved in the My Docs of
whoever is using the file.

This piece of the code is part of a larger code which will remove VBA,
formulas etc to make a smaller file.

Thanks
LiAD

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
Macro to Save without the Save Message Ellen G Excel Discussion (Misc queries) 4 February 23rd 07 08:52 PM
"Save" macro problem, still prompted to save when closing workbook (?) StargateFanFromWork[_4_] Excel Programming 8 September 13th 06 04:49 PM
Totally Disabling (^ save ) (Save as) and Save Icon – Which code do I use: harpscardiff[_10_] Excel Programming 8 November 10th 05 12:24 PM
ASP: Open Excel File with Macro, Allow Macro to run, and then save delgados129 Excel Programming 0 March 10th 05 09:35 PM
Prompted to save changes after macro save - why? Izar Arcturus Excel Programming 2 December 10th 03 09:27 PM


All times are GMT +1. The time now is 05:03 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"