How to save an existing file into a new file using "save as" method?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • asenthil
    New Member
    • Dec 2006
    • 61

    How to save an existing file into a new file using "save as" method?

    Hai to all,

    if i'm having a file named as "tab.doc" which is a microsoft word document file ...

    i want to save it as another file as "tab1.doc" by using

    "save as" method....

    Is there any "save as" method available for doing this process in VC++....

    thanks in advance..
    senthil..
  • asenthil
    New Member
    • Dec 2006
    • 61

    #2
    Hai
    can anybody help me...

    i want to save the content of an existing file into a newly created file by using
    the "save as" method...

    for example if i'm having tab.doc which is a manually created ms word document
    file...

    then i want to the save the contents of tab.doc file into a new file tab1.doc. by

    using "SaveFileAs " method...

    How can i do it..

    Can any body plzz help me..

    Comment

    • Banfa
      Recognized Expert Expert
      • Feb 2006
      • 9067

      #3
      You question is not clear, you have not described your problem in enough detail.

      Why would you want to use C++ for this?
      Why can't you just select Save As from the work menu?
      Why can't you use copy?
      What is the purpose of the program you are trying to write?

      Comment

      • asenthil
        New Member
        • Dec 2006
        • 61

        #4
        Hai...

        thanks for ur reply..

        mainly i want to automate that process in my project...

        Actually i'm a Adobe indesign plugin developer...

        i'm developing indesing plugin's using VC++..

        i want to import a html file into indesign document...

        but indesign does not support html...

        thats y i'm trying import doc file(ms word)...

        ok plzz tell me how to copy the contents of one file(ie tab.doc) into the

        another file(tab1.doc). ...

        is there any source code available for doing this proces...

        plzz help me its very urgent...

        thanks...
        senthil

        Comment

        • Banfa
          Recognized Expert Expert
          • Feb 2006
          • 9067

          #5
          Assuming you have access to the Windows API then I suggest you use

          BOOL CopyFile(
          LPCTSTR lpExistingFileN ame,
          LPCTSTR lpNewFileName,
          BOOL bFailIfExists
          );

          or

          BOOL CopyFileEx(
          LPCTSTR lpExistingFileN ame,
          LPCTSTR lpNewFileName,
          LPPROGRESS_ROUT INE lpProgressRouti ne,
          LPVOID lpData,
          LPBOOL pbCancel,
          DWORD dwCopyFlags
          );


          If you don't have access to the Windows API then you will need to use functions

          fopen
          fclose
          fread
          fwrite

          To open the source and destination files (in binary mode) read data from the source and write data to the destination and then close both files again.

          Comment

          • asenthil
            New Member
            • Dec 2006
            • 61

            #6
            Hai Banfa,

            thanks for ur reply...

            Itz working supervly...

            But this CopyFile() method is not suitable for my project...

            I want only "SaveAs" method for my project....

            Can u please tell me

            How to save an old file into a new fie by using "save as"...

            The manual process is that...

            if there is a file named 1.doc... we will open it with ms word...

            then click file->save as.. button for saving the contents of 1.doc to a
            new file named as 2.doc...

            I want to automate this process in my program using any SaveAs() method
            like CopyFile() method

            is there any source code available for this process...

            plzz help me...

            thanks for ur reply..
            senthil..

            Comment

            • Banfa
              Recognized Expert Expert
              • Feb 2006
              • 9067

              #7
              There is no such method as SaveAs.

              If you open a document in Word and then "Save As" you are effectively copying it which is what CopyFile does.

              Comment

              • asenthil
                New Member
                • Dec 2006
                • 61

                #8
                Hai Banfa,

                thanks for ur suggestions and responses...

                then otherwise...

                Then plzz tell me how to save the content of webpage into an image file...

                in C++...

                i found that saveToFile() is available for doing that...

                i found a sample code in the net also...

                Code:
                void DownloadHtml(void)
                    {
                    CkHttp http;
                
                    CkString strHtml;
                    bool success = http.QuickGetStr("C:/1.html",strHtml);
                
                    // Save the HTML to a file.
                    strHtml.saveToFile("1.jpg");
                	
                    }
                
                But dont know how to use the above function in my project..
                
                it showing errors like 
                'http': identifier not found, even with argument-dependent lookup
                'CkString' : undeclared identifier
                'CkHttp' : undeclared
                identifieri'm a beginner to c++...
                i think these are only small problems...

                will u plzz help me...
                thanks
                senthil..

                Comment

                • Banfa
                  Recognized Expert Expert
                  • Feb 2006
                  • 9067

                  #9
                  That code relies on the classes CkHttp, CkString which are products of Chilkat software. If you have and are willing to spend the several $100 they cost I would suggest that you then contact Chilkat support for help in using them.

                  You may be able to do something with the MFC classes CHttpConnection and CHtmlView. Perhaps you can get CHtmlView to render to a jpg file instead of the screen.

                  Otherwise it's a case of loading the HTML (and related files, css and images for example), rendering it to an image and then saving that image in JPG format.

                  Comment

                  Working...