Home
TeamSite
Setting Save As Options in Word VBA
SirHC
Hi,
I have a requirement to force users to save a document in WorkSite in a particular format.
Essentially the accounts system creates a document in RTF format and opens it in Word (it always has the same file extension of *.BIL), and when the user hits save or save as, I want to be able to set the document type (format) to "Word Document"
I've managed to get this working for enhanced integration, but I want to get it working for classic mode.
How it works now for enhanced is I capture the Word DocumentBeforeSave event, and check the file extension, if it is, then I trigger a WorkSite Save As by doing a SendKeys for F-12 (I couldn't get it to work any other way!) See code below:
Private Sub objApplication_DocumentBeforeSave(ByVal Doc As Document, SaveAsUI As Boolean, Cancel As Boolean)
If UCase(Right(Doc.Name, 4)) = ".BIL" Then
' Do a "Save As" instead of a save
SendKeys "{F12}" ' F-12 is Word's standard File Save As key
End If
End Sub
I then have code that captures the OnInitDialog event for IManFileSaveDlg that sets the SaveAsTypesIndex to 1 (i.e. "Word Document") as per the following code:
Private Sub objIManFileSaveCmdSink_OnInitDialog(ByVal pMyInterface As Object)
If UCase(Right(ActiveDocument.Name, 4)) = ".BIL" Then
' If the document has the extension "BIL" then set the default document save as type to "Word Document"
' [Normally would default to the same type as the document format - in this case RTF]
Set objIManFileSaveDlgSink = pMyInterface
' Set the SaveAsTypesIndex to the first option - "Word Document"
objIManFileSaveDlgSink.SaveAsTypesIndex = 0
End If
End Sub
So now I want to do the same for classic mode and am getting stuck (I haven't had much exposure to working with the older dialogs!) I was hoping it was just a matter of hooking into the SaveAsOptionsCmd and setting the correct value for the index but I can't see a way to do this.
Any suggestions would be greatly appreciated!
Regards
Chris
Find more posts tagged with
Comments
jny
You would need to catch these events for the Classic dialog:
Private WithEvents objExtensibilitySink As iManO2K.iManageExtensibility
Private WithEvents objImportCmdSink As IMANEXTLib.ImportCmd
Private Sub objExtensibilitySink_OnCreateNewProfile(ByVal objImportCmd As Object)
Set objImportCmdSink = objImortCmd
End Sub
Private Sub objImportCmdSink_OnInitDialog(ByVal pMyInterface As Object)
End Sub