+ Reply to Thread
Results 1 to 6 of 6

Excel 2007 create a copy of a file using vb on form

Hybrid View

  1. #1
    colmac
    Guest

    Excel 2007 create a copy of a file using vb on form

    Help for a newbie pls. I've searched the forum but didn't find any suitable answer.

    I’ve created a VB form for use on an Excel 2007 spreadsheet running in compatibility mode.

    Amongst other things, I’m data capturing a Surname and the file name of an image already on the hard disk, and writing this to my spreadsheet with loads of other data. This is working fine.

    I would now like to add a routine to my save button (which already writes the data to the spreadsheet.) I need it now to create a copy of the file whose name I captured and Append the Surname in front of the existing file name.

    So I would data capture

    Label Name Data

    txtsnam Surname Smith

    txtfilenam FileName DSC02345.jpg

    I then want a copy of this file created as

    Smith_DSC02345.jpg

    Working out how to do this is beyond my knowledge & understanding, I can usually work these things out with a few solid hints, but getting the initial start is often beyond me.

    My first steps are

     Dim savnam As String
     Dim newsavnam As String
    
    
       savnam = ("txtimgno")
       newsavnam = ("txtsname" & "_" & "txtfnam" & "_" & "txtimgno")
    
       FileCopy "H:\Doc\Test\V1\[savnam].jpg", "H:\Doc\Test\V1\[newsavnam].jpg"
    this isn't working right, but its a start

    Can anyone help please.

    Thanks

    Colin
    Last edited by colmac; 03-26-2011 at 07:59 AM. Reason: correcting code tags

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Excel 2007 create a copy of a file using vb on form

    To best describe or illustrate your problem you would be better off attaching a dummy workbook, the workbook should contain the same structure and some dummy data of the same type as the type you have in your real workbook - so, if a cell contains numbers & letters in this format abc-123 then that should be reflected in the dummy workbook.

    If needed supply a before and after sheet in the workbook so the person helping you can see what you are trying to achieve.

    Doing this will ensure you get the result you need!
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    colmac
    Guest

    Re: Excel 2007 create a copy of a file using vb on form

    Have solved problem. Thanks

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Excel 2007 create a copy of a file using vb on form

    Your post does not comply with Rule 9 of our Forum RULES. If you solve a problem yourself before anyone else has responded, please take a moment to describe your solution, chances are some other member will benefit. And please never edit a thread in which someone else has responded.

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save

  5. #5
    colmac
    Guest

    Re: Excel 2007 create a copy of a file using vb on form

    I suspect this post will break your rules, but what the heck! Please cancel my memebership of this forum. The only reason I ask is that I cannot see where to do it myself.

    I appreciate the work people put in to make forums work, but I am probably a member of between 10 & 20 other forums, and have never seen one less helpful. Beginners are helped through the earlky stage of membership in other forums and become valued and valuable members through support and encouragement.

    Sorry I do not meet your high demands, I won't bother you again.

  6. #6
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Excel 2007 create a copy of a file using vb on form

    Strangely enough, I thought I helped you despite the amount of work that you made for me by not actually reading the Forum Rules before agreeing to them.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

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