Computer Forum Forum Index
Register  FAQ Profile Log in to check your private messages Log in Register 

Customise 'FileOpen' with new Title

 
Post new topic   Reply to topic    Computer Forum Forum Index -> word vba customization
View previous topic :: View next topic  
Author Message
Greg
Guest





PostPosted: Thu May 03, 2007 12:24 pm    Post subject: Customise 'FileOpen' with new Title Reply with quote

Is it possible to supply a custom title for the Word FileOpen dialog?

Currently experimenting with Excel's GetOpenFilename but having some
problems with a default file location itstead of the current location in
Word. There is also an overhead for instancing excel just for this
function.

Current code listed below:

Public Sub GetFileOpenTest()
Dim strFullFileName As String, strCustomTitle As String, strFileType As
String
strFileType = "Sect 4 documents (*.do*),*.do*"
'CustomTitle = "Custom Dialog Title"
strCustomTitle = "Select a valid Module Section 4"
strFullFileName = xfn_FileOpenGetCustomised(strCustomTitle, strFileType,
CurDir)
End Sub

Public Function xfn_FileOpenGetCustomised(strCustomTitle As String,
strFileType As String, strCurDir As String) As String
'------------------------------------------Vrs
3.00 -------------------------
' Procedure : FileOpenGetCustomised
' DateTime : 03 May 2007 17:15
' Author : Greg Quick
' Purpose : Get an existing filename from a 'FileOpen' Dlg with a
' : Customised dlg title and customise file string
' Syntax : strReturn = xfn_FileOpenGetCustomised(strCustomTitle As
String, strFileType As String)
' : strCustomTitle = "Custom Dialog Title": strFileType = "Sect
4 documents (*.do*),*.do*"
'---------------------------------------------------------------------------------------
'Inputs : strCustomTitle As String, strFileType As String, strCurDir
as string
'Outputs : Nil
'Dependencies : Nil
'---------------------------------------------------------------------------------------
Const strMacroName As String = "FileOpenGetCustomised": Const booLogErrors
As Boolean = False 'error logging is off
Dim strErrLabel As String, booReturn As Boolean 'Err Variables
'--------------------------------------------------------------------------------------
Dim strFullFileName As String
Dim xcl As Object
'On Error GoTo FileOpenGetCustomised_Error
Set xcl = CreateObject("excel.Application")
With xcl
' .Application.ChDrive strCurDir
' .Application.ChDir strCurDir

End With

strFullFileName = xcl.GetOpenFilename(strFileType, 1, strCustomTitle, ,
False)

xfn_FileOpenGetCustomised = strFullFileName

xcl.Quit ' ensure the instance of EXCEL goes away
End Function
Back to top
Google
Sponsor





PostPosted: Thu May 03, 2007 12:24 pm    Post subject: Advertisement

Back to top
Jonathan West
Guest





PostPosted: Thu May 03, 2007 3:02 pm    Post subject: Re: Customise 'FileOpen' with new Title Reply with quote

Which version of Word are you using? What you can do depends on this

--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org

"Greg" <GregQuick@internode.on.net> wrote in message
news:%23$auN4XjHHA.4132@TK2MSFTNGP05.phx.gbl...
Quote:
Is it possible to supply a custom title for the Word FileOpen dialog?

Currently experimenting with Excel's GetOpenFilename but having some
problems with a default file location itstead of the current location in
Word. There is also an overhead for instancing excel just for this
function.

Current code listed below:

Public Sub GetFileOpenTest()
Dim strFullFileName As String, strCustomTitle As String, strFileType As
String
strFileType = "Sect 4 documents (*.do*),*.do*"
'CustomTitle = "Custom Dialog Title"
strCustomTitle = "Select a valid Module Section 4"
strFullFileName = xfn_FileOpenGetCustomised(strCustomTitle, strFileType,
CurDir)
End Sub

Public Function xfn_FileOpenGetCustomised(strCustomTitle As String,
strFileType As String, strCurDir As String) As String
'------------------------------------------Vrs
3.00 -------------------------
' Procedure : FileOpenGetCustomised
' DateTime : 03 May 2007 17:15
' Author : Greg Quick
' Purpose : Get an existing filename from a 'FileOpen' Dlg with a
' : Customised dlg title and customise file string
' Syntax : strReturn = xfn_FileOpenGetCustomised(strCustomTitle As
String, strFileType As String)
' : strCustomTitle = "Custom Dialog Title": strFileType =
"Sect 4 documents (*.do*),*.do*"
'---------------------------------------------------------------------------------------
'Inputs : strCustomTitle As String, strFileType As String, strCurDir
as string
'Outputs : Nil
'Dependencies : Nil
'---------------------------------------------------------------------------------------
Const strMacroName As String = "FileOpenGetCustomised": Const booLogErrors
As Boolean = False 'error logging is off
Dim strErrLabel As String, booReturn As Boolean 'Err Variables
'--------------------------------------------------------------------------------------
Dim strFullFileName As String
Dim xcl As Object
'On Error GoTo FileOpenGetCustomised_Error
Set xcl = CreateObject("excel.Application")
With xcl
' .Application.ChDrive strCurDir
' .Application.ChDir strCurDir

End With

strFullFileName = xcl.GetOpenFilename(strFileType, 1, strCustomTitle, ,
False)

xfn_FileOpenGetCustomised = strFullFileName

xcl.Quit ' ensure the instance of EXCEL goes away
End Function


Back to top
Greg
Guest





PostPosted: Thu May 03, 2007 3:35 pm    Post subject: Re: Customise 'FileOpen' with new Title Reply with quote

Currently using Word XP, and Word 2003
Thank You

"Jonathan West" <jwest@mvps.org> wrote in message
news:%23kgNLRZjHHA.5012@TK2MSFTNGP06.phx.gbl...
Quote:
Which version of Word are you using? What you can do depends on this

--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org

"Greg" <GregQuick@internode.on.net> wrote in message
news:%23$auN4XjHHA.4132@TK2MSFTNGP05.phx.gbl...
Is it possible to supply a custom title for the Word FileOpen dialog?

Currently experimenting with Excel's GetOpenFilename but having some
problems with a default file location itstead of the current location in
Word. There is also an overhead for instancing excel just for this
function.

Current code listed below:

Public Sub GetFileOpenTest()
Dim strFullFileName As String, strCustomTitle As String, strFileType As
String
strFileType = "Sect 4 documents (*.do*),*.do*"
'CustomTitle = "Custom Dialog Title"
strCustomTitle = "Select a valid Module Section 4"
strFullFileName = xfn_FileOpenGetCustomised(strCustomTitle, strFileType,
CurDir)
End Sub

Public Function xfn_FileOpenGetCustomised(strCustomTitle As String,
strFileType As String, strCurDir As String) As String
'------------------------------------------Vrs
3.00 -------------------------
' Procedure : FileOpenGetCustomised
' DateTime : 03 May 2007 17:15
' Author : Greg Quick
' Purpose : Get an existing filename from a 'FileOpen' Dlg with a
' : Customised dlg title and customise file string
' Syntax : strReturn = xfn_FileOpenGetCustomised(strCustomTitle As
String, strFileType As String)
' : strCustomTitle = "Custom Dialog Title": strFileType =
"Sect 4 documents (*.do*),*.do*"
'---------------------------------------------------------------------------------------
'Inputs : strCustomTitle As String, strFileType As String,
strCurDir as string
'Outputs : Nil
'Dependencies : Nil
'---------------------------------------------------------------------------------------
Const strMacroName As String = "FileOpenGetCustomised": Const
booLogErrors As Boolean = False 'error
logging is off
Dim strErrLabel As String, booReturn As Boolean 'Err Variables
'--------------------------------------------------------------------------------------
Dim strFullFileName As String
Dim xcl As Object
'On Error GoTo FileOpenGetCustomised_Error
Set xcl = CreateObject("excel.Application")
With xcl
' .Application.ChDrive strCurDir
' .Application.ChDir strCurDir

End With

strFullFileName = xcl.GetOpenFilename(strFileType, 1, strCustomTitle, ,
False)

xfn_FileOpenGetCustomised = strFullFileName

xcl.Quit ' ensure the instance of EXCEL goes away
End Function



Back to top
Jonathan West
Guest





PostPosted: Thu May 03, 2007 10:26 pm    Post subject: Re: Customise 'FileOpen' with new Title Reply with quote

"Greg" <GregQuick@internode.on.net> wrote in message
news:uwxEQjZjHHA.4464@TK2MSFTNGP03.phx.gbl...
Quote:
Currently using Word XP, and Word 2003
Thank You

In that case, look up the FileDialog object in the Word VBA Help. It allows
you to display a customized File Open, File Save As or Folder dialog. There
are properties that allow you to customize rhe dialog, including the Title
property that allows you to set the caption.


--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Computer Forum Forum Index -> word vba customization All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Computer Forum