F
felton
I have this code from an 'OK' button on a form which simply allows the user
select to create a New Blank Document, or insert other types of files. The
problem area is inserting the new blank document because I need to become the
active document. So whatever other documents are open at the time, they need
to remain open and go to the background, and the new blank document has to
become active.
Can anyone help with the correct code I need to use and where to use it?
Thanks
=======================================
Private Sub btnOK_Click()
Dim Today As String, FirstInit As String, Name As String, Dir As String,
ChangeDir As String
Dim NewDoc As Byte
ChangeDir = Me.lbxProfessionals.Value
Today = " "
FirstInit = ChangeDir
Name = Application.UserInitials
Order = " "
Dir = "G:\" & ChangeDir & "\"
MakeFileName Today, FirstInit, Order, Dir
Name = Dir & Today & "_" & Name & Order & ".doc"
Select Case Choice
Case 0
Application.ChangeFileOpenDirectory "F:\TEMPLATES"
Documents.Add Template:="Document", NewTemplate:=True
Case 1
Case 2
Case Else
End Select
With Application.Dialogs(wdDialogFileSaveAs)
.Format = wdFormatDocument
End With
If ActiveDocument.SaveFormat = wdFormatTemplate Then
ActiveDocument.SaveAs FileFormat:=wdFormatDocument
End If
ActiveDocument.SaveAs FileName:=Name, FileFormat:= _
wdFormatDocument, LockComments:=False, Password:="",
AddToRecentFiles:= _
True, WritePassword:="", ReadOnlyRecommended:=False,
EmbedTrueTypeFonts:= _
False, SaveNativePictureFormat:=False, SaveFormsData:=False, _
SaveAsAOCELetter:=False
Call CreateFooter
Selection.WholeStory
Selection.MoveDown Unit:=wdLine, Count:=1, Extend:=wdMove
Unload Me
End
End Sub
=======================================
Thanks again
select to create a New Blank Document, or insert other types of files. The
problem area is inserting the new blank document because I need to become the
active document. So whatever other documents are open at the time, they need
to remain open and go to the background, and the new blank document has to
become active.
Can anyone help with the correct code I need to use and where to use it?
Thanks
=======================================
Private Sub btnOK_Click()
Dim Today As String, FirstInit As String, Name As String, Dir As String,
ChangeDir As String
Dim NewDoc As Byte
ChangeDir = Me.lbxProfessionals.Value
Today = " "
FirstInit = ChangeDir
Name = Application.UserInitials
Order = " "
Dir = "G:\" & ChangeDir & "\"
MakeFileName Today, FirstInit, Order, Dir
Name = Dir & Today & "_" & Name & Order & ".doc"
Select Case Choice
Case 0
Application.ChangeFileOpenDirectory "F:\TEMPLATES"
Documents.Add Template:="Document", NewTemplate:=True
Case 1
Case 2
Case Else
End Select
With Application.Dialogs(wdDialogFileSaveAs)
.Format = wdFormatDocument
End With
If ActiveDocument.SaveFormat = wdFormatTemplate Then
ActiveDocument.SaveAs FileFormat:=wdFormatDocument
End If
ActiveDocument.SaveAs FileName:=Name, FileFormat:= _
wdFormatDocument, LockComments:=False, Password:="",
AddToRecentFiles:= _
True, WritePassword:="", ReadOnlyRecommended:=False,
EmbedTrueTypeFonts:= _
False, SaveNativePictureFormat:=False, SaveFormsData:=False, _
SaveAsAOCELetter:=False
Call CreateFooter
Selection.WholeStory
Selection.MoveDown Unit:=wdLine, Count:=1, Extend:=wdMove
Unload Me
End
End Sub
=======================================
Thanks again