wildarmsdave
asked on
VB6 Open word doc and set compression options
Hi everyone. Is the below possible in VB6? I have hundreds of word documents that I need to compress to save space on our file server and I thought about doing the following to make things easier...
Ta - Dave
I need to search a folder and sub folders for all word documents
open each one individually
active the file save as command
activate the tools - compress pictures option
Set all pictures in document, web/screen, compress pictures, delete cropped areas option
Save the document with the same filename
Ta - Dave
I need to search a folder and sub folders for all word documents
open each one individually
active the file save as command
activate the tools - compress pictures option
Set all pictures in document, web/screen, compress pictures, delete cropped areas option
Save the document with the same filename
ASKER
Yeah ,I tried that first but the Macro didn't appear to list the code to carry out the conversion.
I think that it is a option in Word and default it is set to compress.
-FA
-FA
ASKER
FarzadA it does, however, the images in the documents in question are at a higher DPI resolution than what is needed. By setting the web/screen option, I reduce the file size even more.
ASKER
Well the following line of VBA code will open up the compression menu. I just need to find a way to get the send keys function to interact with the menu
Application.CommandBars.Fi ndControl( ID:=6382). Execute
Application.CommandBars.Fi
ASKER
With a slight revision of the code, I can now get the sendkeys command to work. So I can now open up the picture toolbar, set my options, Okay my choices and save the compressed file. All I need to do now is to search for all word docs, open them and activate the code below!!!! I may have to dso this from VBA which is not a problem. One snag I am finding is that if I open a new word doc and insert and run the code, it works. However, if I SAVE the word doc and then run the code. Nothing happens! Something to look at later I think!
Dim octl As CommandBarControl
Set octl = Application.CommandBars.Fi ndControl( ID:=6382)
SendKeys "%w"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "~"
SendKeys "%f"
' Save file here.....
octl.Execute
Dim octl As CommandBarControl
Set octl = Application.CommandBars.Fi
SendKeys "%w"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "~"
SendKeys "%f"
' Save file here.....
octl.Execute
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
An easy solution: Open Word and start recording macro and do the above batch. After stop recording macro and view the VB code of macro. Use it in your VB6 application.
-FA