By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,506 Members | 1,876 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,506 IT Pros & Developers. It's quick & easy.

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

P: 61
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..
Jan 10 '07 #1
Share this Question
Share on Google+
8 Replies


P: 61
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..
Jan 10 '07 #2

Banfa
Expert Mod 5K+
P: 8,916
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?
Jan 10 '07 #3

P: 61
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
Jan 10 '07 #4

Banfa
Expert Mod 5K+
P: 8,916
Assuming you have access to the Windows API then I suggest you use

BOOL CopyFile(
LPCTSTR lpExistingFileName,
LPCTSTR lpNewFileName,
BOOL bFailIfExists
);

or

BOOL CopyFileEx(
LPCTSTR lpExistingFileName,
LPCTSTR lpNewFileName,
LPPROGRESS_ROUTINE lpProgressRoutine,
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.
Jan 10 '07 #5

P: 61
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..
Jan 11 '07 #6

Banfa
Expert Mod 5K+
P: 8,916
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.
Jan 11 '07 #7

P: 61
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...

Expand|Select|Wrap|Line Numbers
  1. void DownloadHtml(void)
  2.     {
  3.     CkHttp http;
  4.  
  5.     CkString strHtml;
  6.     bool success = http.QuickGetStr("C:/1.html",strHtml);
  7.  
  8.     // Save the HTML to a file.
  9.     strHtml.saveToFile("1.jpg");
  10.  
  11.     }
  12.  
  13. But dont know how to use the above function in my project..
  14.  
  15. it showing errors like 
  16. 'http': identifier not found, even with argument-dependent lookup
  17. 'CkString' : undeclared identifier
  18. 'CkHttp' : undeclared
identifieri'm a beginner to c++...
i think these are only small problems...

will u plzz help me...
thanks
senthil..
Jan 11 '07 #8

Banfa
Expert Mod 5K+
P: 8,916
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.
Jan 11 '07 #9

Post your reply

Sign in to post your reply or Sign up for a free account.