CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    May 2012

    How to open current word document? Please help me...

    In the database saving a lots of files which are differentiate by ID. Same ID could have more than one but different date. Im trying to create the code to retrieve the word document with latest current date:

    If FileExist(strFileName) Then
    objword.Documents.Open strFileName
    Call WordSetting("Protect")
    ElseIf FileExist(strNewFileName) Then
    Set objTempWord = New Word.Application
    objTempWord.Visible = False
    'strNewFileName = Format(Date, "MM/DD/YYYY")
    objTempWord.Documents.Open strNewFileName, "", "", "", "", "", "", "", "", Format(strNewFileNa me, "DD/MMM/YYYY hh:nn:ss", "", vbUseSystem)
    Call WordSetting("Protect")

    Function for FileExist:

    Public Function FileExist(strFileExist As String) As Boolean
    On Error GoTo SystemError

    Dim fs As Object

    Set fs = CreateObject("Scripting.FileSystemObject")

    FileExist = fs.FileExists(strFileExist)

    Set fs = Nothing

    On Error GoTo 0
    Exit Function

  2. #2
    Join Date
    May 2012

    Re: How to open current word document? Please help me...

    objTempWord.Documents.Open strNewFileName, "", "", "", "", "", "", "", "", Format(strNewFileName, "DD/MMM/YYYY hh:nn:ss", "", vbUseSystem)

    Cause the error " Type mismatch...."...

  3. #3
    Join Date
    Jan 2006
    Fox Lake, IL

    Re: How to open current word document? Please help me...

    Change the line to:

    objTempWord.Documents.Open strNewFileName, "
    and it will open the available options (if you did things right)

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.