Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-06-2014, 01:04 PM
steveneashcraft steveneashcraft is offline How to suppress saveas dialog from VB6 Windows 7 64bit How to suppress saveas dialog from VB6 Office 2010 64bit
Novice
How to suppress saveas dialog from VB6
 
Join Date: May 2014
Posts: 8
steveneashcraft is on a distinguished road
Default How to suppress saveas dialog from VB6


I have an application written in VB6. Once I have created a word document within the application and do a saveas the save as dialog pop ups and my application waits for the user to click on "Save".
I have set the filename and file format before calling saveas.
Since this application is supposed to run unattended as an application this is a problem.
This worked with Office 2003 but when we upgraded to Office 2010 we now have the application waiting for a user to click "Save"
Any ideas on what setting I need to change so that the Save dialog is suppressed and the file is just saved based on the filename and type set in the VB6 application?
Thanks.
Reply With Quote
  #2  
Old 05-06-2014, 04:09 PM
macropod's Avatar
macropod macropod is offline How to suppress saveas dialog from VB6 Windows 7 32bit How to suppress saveas dialog from VB6 Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Is there a reason you're working through the SaveAs dialogue, rather than using .SaveAs?
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 05-07-2014, 08:43 AM
steveneashcraft steveneashcraft is offline How to suppress saveas dialog from VB6 Windows 7 64bit How to suppress saveas dialog from VB6 Office 2010 64bit
Novice
How to suppress saveas dialog from VB6
 
Join Date: May 2014
Posts: 8
steveneashcraft is on a distinguished road
Default

Quote:
Originally Posted by steveneashcraft View Post
I have an application written in VB6. Once I have created a word document within the application and do a saveas the save as dialog pop ups and my application waits for the user to click on "Save".
I have set the filename and file format before calling saveas.
Since this application is supposed to run unattended as an application this is a problem.
This worked with Office 2003 but when we upgraded to Office 2010 we now have the application waiting for a user to click "Save"
Any ideas on what setting I need to change so that the Save dialog is suppressed and the file is just saved based on the filename and type set in the VB6 application?
Thanks.
I found another clue. The original document that I want to open and then do a save as word document is being created with an internal format of rtf.
Apparently Office 2003 was willing to open a document that was rtf internally and then save it back to the same name but using the Office 2003 Word doc format without asking for confirmation from the user.
This was how the application was able to provide different internal formats for .doc files.
I think Microsoft has changed the rules again and I am just out of luck.
Does anyone have any ideas.
Reply With Quote
  #4  
Old 05-07-2014, 04:14 PM
macropod's Avatar
macropod macropod is offline How to suppress saveas dialog from VB6 Windows 7 32bit How to suppress saveas dialog from VB6 Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

That's all very well, but it still doesn't explain why you're trying to work through the dialogues instead of using the .SaveAs method - using the dialogues has never been necessary and using the .SaveAs method avoids any prompts. Done properly, even using the dialogues should be completely transparent. As you haven't posted any code, though, I can't comment on what its issues might be.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #5  
Old 05-07-2014, 05:18 PM
steveneashcraft steveneashcraft is offline How to suppress saveas dialog from VB6 Windows 7 64bit How to suppress saveas dialog from VB6 Office 2010 64bit
Novice
How to suppress saveas dialog from VB6
 
Join Date: May 2014
Posts: 8
steveneashcraft is on a distinguished road
Default

I am using the SaveAs method and I am setting the format but Word still prompts me as the file that I have open is rtf. If I have opened a file whose internal format is Word doc then Word doesn't display the Save dialog. Here's some code


Code:
Private Sub Form_Load()
On Error GoTo testerr
Dim WW As Object
Dim FileName As String
Dim SaveFormat As Long
FileName = "C:\tmp\test.doc"
SaveFormat = 0
Set WW = CreateObject("Word.Application")
WW.Visible = True
WW.Documents.Open FileName
WW.activedocument.SaveAs FileFormat:=SaveFormat
WW.activedocument.Close
 
Exit Sub
testerr:
MsgBox ("error occurred " & Err.Description)
End Sub
You need to create c:\tmp\test.doc as a file with an internal format of rtf.
Word still allows you to do that but you will have to rename the file to test.doc.
Create a VB6 project with just a form and run it.
Save dialog will come up every time and I have no idea how to tell Word that I really want to save this file as a file with doc or docx internal format.

Too bad Word keeps getting modified so that it is "better".

If you create a file that is really a doc file and run the code then Save dialog does not come up.

I'm open to any thoughts on how I can do this from a MS MVP Word expert.
Currently probably going to have go with a kludge like ClickOff.

Thanks

Last edited by macropod; 05-07-2014 at 06:54 PM. Reason: Added code tags
Reply With Quote
  #6  
Old 05-07-2014, 07:07 PM
macropod's Avatar
macropod macropod is offline How to suppress saveas dialog from VB6 Windows 7 32bit How to suppress saveas dialog from VB6 Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

The prompt is most likely due to the fact that the document was originally opened in one format and is being saved in another but you're not releasing the version in its original format. I would expect Word to behave this way in all versions. All you need do is change:
WW.ActiveDocument.Close
to:
WW.ActiveDocument.Close False

PS: I also note that, although you have:
FileName = "C:\tmp\test.doc
you don't use it in:
WW.activedocument.SaveAs FileFormat:=SaveFormat
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #7  
Old 05-08-2014, 07:27 AM
steveneashcraft steveneashcraft is offline How to suppress saveas dialog from VB6 Windows 7 64bit How to suppress saveas dialog from VB6 Office 2010 64bit
Novice
How to suppress saveas dialog from VB6
 
Join Date: May 2014
Posts: 8
steveneashcraft is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
The prompt is most likely due to the fact that the document was originally opened in one format and is being saved in another but you're not releasing the version in its original format. I would expect Word to behave this way in all versions. All you need do is change:
WW.ActiveDocument.Close
to:
WW.ActiveDocument.Close False

PS: I also note that, although you have:
FileName = "C:\tmp\test.doc
you don't use it in:
WW.activedocument.SaveAs FileFormat:=SaveFormat
So are you saying that changing the close statement which is executed after the saveas is going to solve my problem? Since the save dialog is displayed prior to calling the close and the application is waiting for the save dialog to be completed your suggestion doesn't make sense to me.

But like any good newby I tried it which you obviously didn't and it didn't help which was not much of a surprise.

I really appreciate your time and effort in looking at my problem.
Reply With Quote
  #8  
Old 05-08-2014, 03:04 PM
macropod's Avatar
macropod macropod is offline How to suppress saveas dialog from VB6 Windows 7 32bit How to suppress saveas dialog from VB6 Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Did you try it?
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #9  
Old 05-08-2014, 04:20 PM
steveneashcraft steveneashcraft is offline How to suppress saveas dialog from VB6 Windows 7 64bit How to suppress saveas dialog from VB6 Office 2010 64bit
Novice
How to suppress saveas dialog from VB6
 
Join Date: May 2014
Posts: 8
steveneashcraft is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
Did you try it?
That's what I said in my previous post.

I tried it but you obviously didn't try your solution or you would have found out that it doesn't work for the reasons that I also put in my previous post.
Reply With Quote
  #10  
Old 05-08-2014, 04:27 PM
macropod's Avatar
macropod macropod is offline How to suppress saveas dialog from VB6 Windows 7 32bit How to suppress saveas dialog from VB6 Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

It works for me...

Although it shouldn't be necessary, you might try changing:
WW.activedocument.SaveAs FileFormat:=SaveFormat
to:
WW.activedocument.SaveAs2 FileFormat:=SaveFormat
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #11  
Old 05-08-2014, 04:32 PM
steveneashcraft steveneashcraft is offline How to suppress saveas dialog from VB6 Windows 7 64bit How to suppress saveas dialog from VB6 Office 2010 64bit
Novice
How to suppress saveas dialog from VB6
 
Join Date: May 2014
Posts: 8
steveneashcraft is on a distinguished road
Default

Can you send me the file that you test that is rich text format so I verify that it's not something that I am doing wrong when creating my rtf file?
Thanks
Reply With Quote
  #12  
Old 05-08-2014, 04:59 PM
macropod's Avatar
macropod macropod is offline How to suppress saveas dialog from VB6 Windows 7 32bit How to suppress saveas dialog from VB6 Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

See attached. As I don't have VB6, I'm running the code as an ordinary macro from within the document itself. I've modified the code to save the file to the desktop. The macro is in the 'ThisDocument' module.
Attached Files
File Type: zip Sample.zip (13.9 KB, 11 views)
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #13  
Old 05-08-2014, 05:21 PM
steveneashcraft steveneashcraft is offline How to suppress saveas dialog from VB6 Windows 7 64bit How to suppress saveas dialog from VB6 Office 2010 64bit
Novice
How to suppress saveas dialog from VB6
 
Join Date: May 2014
Posts: 8
steveneashcraft is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
See attached. As I don't have VB6, I'm running the code as an ordinary macro from within the document itself. I've modified the code to save the file to the desktop. The macro is in the 'ThisDocument' module.
The file you sent me was not internally an rtf file. It did have an rtf suffix but if you examine the contents using a tool that shows you the binary contents of the file you will see that it is not an rtf file. It looks like a doc or a docx file and consequently your test worked. My program works if you start with a file that has doc or docx format internally and try to save it as a doc file. The problem is that if you open a real rtf file and then try to save it as a doc file you cannot suppress the Save dialog.

It appears that you are confused about internal formats and the suffix that a file has. A file with a suffix of rtf does not mean that the internal contents are rtf.
Reply With Quote
  #14  
Old 05-08-2014, 05:31 PM
macropod's Avatar
macropod macropod is offline How to suppress saveas dialog from VB6 Windows 7 32bit How to suppress saveas dialog from VB6 Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

I created the file in Word 2010 and used SaveAs to save it as an RTF file. I didn't then go an examine the contents, as I expected the output to conform to the RTF specifications. I am not confused as to formats vs file extensions. I suppose I should have twigged to something being amiss when it allowed me to save the file with the macro. Attached is another file - this time a true RTF. The macro that's in the other one works fine with this file too.
Attached Files
File Type: zip Sample.zip (12.6 KB, 11 views)
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #15  
Old 05-09-2014, 05:52 AM
steveneashcraft steveneashcraft is offline How to suppress saveas dialog from VB6 Windows 7 64bit How to suppress saveas dialog from VB6 Office 2010 64bit
Novice
How to suppress saveas dialog from VB6
 
Join Date: May 2014
Posts: 8
steveneashcraft is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
I created the file in Word 2010 and used SaveAs to save it as an RTF file. I didn't then go an examine the contents, as I expected the output to conform to the RTF specifications. I am not confused as to formats vs file extensions. I suppose I should have twigged to something being amiss when it allowed me to save the file with the macro. Attached is another file - this time a true RTF. The macro that's in the other one works fine with this file too.
I think I understand why we are not communicating very well. I thought you, as an expert in Word, knew that doing this operation with Word was the same as doing it from within VB6.
Apparently it isn't
Try this code snippet using cscript and then we will be comparing apples to apples. I have used both Windows 7 (32 bit) , Windows 2008 R2, and XP to demonstrate that the Save dialog always comes up with Word 2010 or Word 1013.

I realize this is not strictly a Word question but it does have to do with the Word object.


Dim WW
Dim FileName
Dim SaveFormat
FileName = "C:\tmp\sample.rtf"
SaveFormat = 0
Set WW = CreateObject("Word.Application")
WW.Visible = True
WW.Documents.Open FileName
call WW.activedocument.SaveAs (FileName, SaveFormat)
WW.activedocument.Close False


where c:\tmp\sample.rtf is internally an rtf file.

The last sample.rtf file you sent me was internally an rtf file.
Thanks again.
Reply With Quote
Reply

Tags
save as, suppress



Similar Threads
Thread Thread Starter Forum Replies Last Post
Disabling Word's Save and SaveAs commands Catty Word VBA 6 03-19-2014 03:21 AM
How to suppress saveas dialog from VB6 Saveas error handling jillapass Word VBA 7 03-30-2012 03:24 PM
How to suppress saveas dialog from VB6 saveAs ChDir _ tinfanide Excel Programming 4 11-05-2011 01:40 AM
Suppress Dialog Box crutch024 Word 0 08-17-2010 09:52 AM
How to suppress saveas dialog from VB6 Suppress "do you want to save?" dialog on close rnstewart Excel 2 12-28-2005 04:30 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 11:55 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft