Results 1 to 9 of 9

Thread: Copy template to user’s pc

  1. #1

    Thread Starter
    New Member String-0's Avatar
    Join Date
    Mar 2006
    Posts
    11

    Talking Copy template to user’s pc

    I told you guys i will come everyday !

    Small problem .. i thought i would ask before looking for a solution .. lets see who is faster

    Template is somewhere on a server .. it’s a small PC not really a server …
    What i need is an automation where it controls if the template is not copyed to a user pc’s it will copy it for him/her with specific path like c:\somewhere\indTemplate… , I need that kind of system is cos most of the users have laptops and they don’t work on network , every now and then they log in to upload there files and data .. that is all ...

  2. #2
    Frenzied Member DKenny's Avatar
    Join Date
    Sep 2005
    Location
    on the good ship oblivion..
    Posts
    1,171

    Re: Copy template to user’s pc

    Here's a procedure I use to download a template. You will need to tweak the constants, but it should get you started...

    VB Code:
    1. Option Explicit
    2.  
    3. ' Filename constants.
    4. Public Const gsFILE_DPS_PRICING_MODEL As String = "DPS_Pricing_Model.xlt"
    5. Public Const gsAPP_DIRECTORY As String = "C:\Pricing_Model\"
    6.  
    7. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    8. ' Comments:     This procedure downloads a new copy of the
    9. '               Pricing Model template.
    10. '
    11. ' Arguments:    None
    12. '
    13. ' Date          Developer       Action
    14. ' --------------------------------------------------------------
    15. ' 01/13/06      Declan Kenny    Initial version
    16.  
    17. Public Sub DownLoadTemplate()
    18.  
    19. Const sDOWNLOAD_DRIVE As String = "your network address"
    20.    
    21. Dim wkbTemplate As Workbook
    22.    
    23.     Set wkbTemplate = Workbooks.Open(Filename:=sDOWNLOAD_DRIVE & gsFILE_DPS_PRICING_MODEL)
    24.    
    25.     wkbTemplate.SaveAs Filename:=gsAPP_DIRECTORY & gsFILE_DPS_PRICING_MODEL, _
    26.                         FileFormat:=xlTemplate
    27.    
    28.     wkbTemplate.Close False
    29.    
    30.     Set wkbTemplate = Nothing
    31. End Sub
    Declan

    Don't forget to mark your Thread as resolved.
    Take a moment to rate posts that you think are helpful

  3. #3

    Thread Starter
    New Member String-0's Avatar
    Join Date
    Mar 2006
    Posts
    11

    Exclamation Re: Copy template to user’s pc

    hi D.

    Thx for the reply .. i will say it who know i might need it one day ,
    I was busy today with the template , I realised I was wrong with what I need.

    I made a template for Adobe Indsign the point of the template that users will only use specific paragraph styles in WORD so when they import them in it will matches the styles automatically , it work perfectly in a way that made me made 5 different kind of templates

    But what I need now is like a system to let my users update the last edit templates every now and then
    What I do now is make a WORD template put it in the same Dir for the ind. Template all the components that belong to that template that is how it will be easier for my users to get every thing in one directory

    Your update system is is perfect , but I would love now to let my users , when they start that word template it should copy the full ind Dir & files in it from the server to there local station like that :
    Copy from:
    G:\IND templates\A4

    Paste in :
    C:\Projacts doc\A4


    Your think its possible ??

    I made a small function for word files , but for a DIR

    PS: am not a programmer but I can find my way around

  4. #4
    Frenzied Member DKenny's Avatar
    Join Date
    Sep 2005
    Location
    on the good ship oblivion..
    Posts
    1,171

    Re: Copy template to user’s pc

    Sure its possible...
    Here's a procedure that take a source path and a destination path and then copies all files from the source to the destination.
    The testit sub hows how you would use this procedure.

    VB Code:
    1. Sub testit()
    2.     String_O_FileCopy "C:\data\testsource\", "C:\data\testdestination\"
    3. End Sub
    4.  
    5. Sub String_O_FileCopy(SourceDir As String, DestinationDir As String)
    6. Dim sFileName As String
    7. Dim sSource As String
    8. Dim sDestination As String
    9.    
    10.     'Make sure the paths end with a slash
    11.     If Right(SourceDir, 1) <> "\" Then SourceDir = SourceDir & "\"
    12.     If Right(DestinationDir, 1) <> "\" Then DestinationDir = DestinationDir & "\"
    13.    
    14.     'Get the first file name
    15.     'in the Source
    16.     sFileName = Dir(SourceDir)
    17.    
    18.     'Loop through all files
    19.     Do While sFileName <> ""
    20.        
    21.         'Fully qualified source path
    22.         sSource = SourceDir & sFileName
    23.        
    24.         'Fully qualified destination path
    25.         sDestination = DestinationDir & sFileName
    26.        
    27.         'Copy the file to the new location
    28.         FileCopy sSource, sDestination
    29.        
    30.         'Move to the next file
    31.         sFileName = Dir
    32.     Loop
    33. End Sub
    Declan

    Don't forget to mark your Thread as resolved.
    Take a moment to rate posts that you think are helpful

  5. #5

    Thread Starter
    New Member String-0's Avatar
    Join Date
    Mar 2006
    Posts
    11

    Re: Copy template to user’s pc

    it worked perfectly but .. it copy only files
    but what if some ppl. didn’t make the dir .. they just run the script ? i tried something like that



    If FolderExists("c:\MyFolder") = True Then
    'dont make folder just copy files

    Else
    'make Dir and
    and copy Files Folder

    End If

  6. #6
    Frenzied Member DKenny's Avatar
    Join Date
    Sep 2005
    Location
    on the good ship oblivion..
    Posts
    1,171

    Re: Copy template to user’s pc

    String-O
    Can you post the code for what you tried?

    You should be using a MkDir statement to create the directory.
    Declan

    Don't forget to mark your Thread as resolved.
    Take a moment to rate posts that you think are helpful

  7. #7

    Thread Starter
    New Member String-0's Avatar
    Join Date
    Mar 2006
    Posts
    11

    Re: Copy template to user’s pc

    this is what i was busy with

    VB Code:
    1. Sub getINDcomp
    2.  
    3. Dim DirIND As New FileSystemObject
    4. If DirIND .DriveExists("c:\INDFOLDER") = True Then
    5.     'just copy
    6. Else
    7.     MsgBox "Boy are you in big trouble!"
    8.  
    9. DirIND .CreateFolder "c:\INDFOLDER"
    10.  
    11. ' and copy Files
    12.  
    13. End If
    14.  
    15. end sub

  8. #8
    Frenzied Member DKenny's Avatar
    Join Date
    Sep 2005
    Location
    on the good ship oblivion..
    Posts
    1,171

    Re: Copy template to user’s pc

    You are all most there. Rather than using the DriveExists method you should be using the FolderExists method. The easiest thing to do here is check to see if the folder exists and if it soesn't - then create it. After that you can continue with the code as above.
    VB Code:
    1. Sub String_O_FileCopy(SourceDir As String, DestinationDir As String)
    2. Dim oDirIND As Scripting.FileSystemObject
    3. Dim sFileName As String
    4. Dim sSource As String
    5. Dim sDestination As String
    6.    
    7.     'Make sure the paths end with a slash
    8.     If Right(SourceDir, 1) <> "\" Then SourceDir = SourceDir & "\"
    9.     If Right(DestinationDir, 1) <> "\" Then DestinationDir = DestinationDir & "\"
    10.    
    11.     Set oDirIND = New Scripting.FileSystemObject
    12.    
    13.     'If the destination folder doesn't exit then
    14.     'create it
    15.     If Not oDirIND.FolderExists(DestinationDir) Then
    16.         oDirIND.CreateFolder DestinationDir
    17.     End If
    18.    
    19.     Set oDirIND = Nothing
    20.    
    21.     'Get the first file name
    22.     'in the Source
    23.     sFileName = Dir(SourceDir)
    24.    
    25.     'Loop through all files
    26.     Do While sFileName <> ""
    27.        
    28.         'Fully qualified source path
    29.         sSource = SourceDir & sFileName
    30.        
    31.         'Fully qualified destination path
    32.         sDestination = DestinationDir & sFileName
    33.        
    34.         'Copy the file to the new location
    35.         FileCopy sSource, sDestination
    36.        
    37.         'Move to the next file
    38.         sFileName = Dir
    39.     Loop
    40. End Sub
    Declan

    Don't forget to mark your Thread as resolved.
    Take a moment to rate posts that you think are helpful

  9. #9

    Thread Starter
    New Member String-0's Avatar
    Join Date
    Mar 2006
    Posts
    11

    Re: Copy template to user’s pc

    Do u mean with SourceDir like that ...
    and would work if i add it on AutoOpen ?


    If Right(SourceDir, 1) <> "\" Then SourceDir = C:\MynewDir& "\"

    If Right(DestinationDir, 1) <> "\" Then DestinationDir = G:\Orginaldir& "\"
    Last edited by String-0; Mar 13th, 2006 at 03:16 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width