Results 1 to 4 of 4

Thread: VB script or code to open copy and paste in file

  1. #1
    Join Date
    Apr 2012
    Posts
    33

    VB script or code to open copy and paste in file

    First of all let me know whether what I have asked is possible or not? I am not well aware of VB Script; you can take me as a new entry to this language. I need to learn some coding in VB script for opening a file then coping data from it and then pasting it completely. Everything should be performed automatically using scripting code. The data copy pasting should be performed between two file. Data should be opened in a file then copied and pasted onto another file and then also the file should be saved with a new name. Trust me as I already said that I am not well aware of VB script so therefore I am also unable to make out whether it is really easy and possible to perform. Anyways its on you people to guide and help me further.

  2. #2
    Join Date
    Apr 2009
    Posts
    491

    Re: VB script or code to open copy and paste in file

    Depends on what format of files you are trying to involve in the task. I mean to say that if you are trying to perform the manipulation of the data of a complex then it would have been quite impossible but if you are involving a text file rather than any other file then I must say you can easily achieve your target.

    Anyways if in case you are really trying your hands with text file then the only thing I would suggest you is to start with filesystemobject. This filesystemobject search only work with text files. Another thing I would like to tell you that copy a data or a program in order to transfer them from one file to another would be much easier with a Copy Program only if you need your script to be able to call other programs.

  3. #3
    Join Date
    May 2009
    Posts
    542

    Re: VB script or code to open copy and paste in file

    In a simple language the above person means to say that in such programs the codes are written on the basis of the file format. Copy Program is a good option I must say. This program is something that will have to undertake within the batch file or a command line for copying the file. The syntax you could use is Copy Source Destination. Using a VB Script code you can do it in the following manner:

    set WSshell = createobject("wscript.shell")
    WSshell.run("copy c:\foldername\filename.txt c:\folder2name\file2name.txt",1)

    Just try this out and let me know the result.

  4. #4
    Join Date
    Mar 2010
    Posts
    154

    Re: VB script or code to open copy and paste in file

    Using a Shell initially game me some errors. Obviously the errors are not at all understandable by me. The error message also produces some error code. I have tried running the following code:
    Shell "notepad.exe c:\foldername\filename.txt", vbMaximizedFocus

    Later on found that I followed the code wrongly. Actually the syntax belonged to Visual Basic Application. Then however after a long research I got the correct code for VB script. It was as follows:
    set WSshell = createobject("wscript.shell")
    WSshell.run("notepad.exe c:\foldername\filename.txt", 1)

Similar Threads

  1. How to copy paste file in Micromax Funbook
    By Ogan in forum Portable Devices
    Replies: 3
    Last Post: 12-07-2012, 06:13 PM
  2. Replies: 5
    Last Post: 26-04-2012, 04:16 AM
  3. Excel file corrupted because of copy paste between files
    By RopeME in forum MS Office Support
    Replies: 2
    Last Post: 25-01-2012, 03:52 PM
  4. How to bypass the open file security warning in vb script
    By Quasim in forum Software Development
    Replies: 5
    Last Post: 05-07-2011, 07:27 PM
  5. Replies: 0
    Last Post: 18-03-2009, 10:00 PM

Posting Permissions

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