• FileSaveAs ‘fix’ causes problem with conversion (Win 98 / Word 97 (both Dutch))

    Home » Forums » AskWoody support » Productivity software by function » Visual Basic for Applications » FileSaveAs ‘fix’ causes problem with conversion (Win 98 / Word 97 (both Dutch))

    Author
    Topic
    #399601

    I replaced the standard FileSaveAs with my own Sub FileSaveAs. Basically it checks first if the document is based on a company template and, if so, fills some fields and then returns handling to Word. Originally with Dialogs(wdDialogFileSaveAs).Show. But due to a issue with Password to Open I changed that according to http://www.mvps.org/word/FAQs/MacrosVBA/Sa…ordsContent.htm%5B/url%5D to:
    With Dialogs(wdDialogFileSaveAs)
    If .Display = -1 Then
    strFileName = .Name
    .Update
    .Name = strFileName
    .Execute
    End If
    End With

    (The other workaround in the same article doesn’t work.)

    But this workaround appeared to cause another problem. Whe the user chooses to save as Textdocument in the Save as dialog, the document is saved as MyDoc.txt allright, but the content is still a Word document!
    Replace the workaround with the original code and the conversion to TXT file does it’s job again.
    So I seem to be stuck between the devil and the deep blue see. Unless someone has onother workaround that solves both problems…

    Thanks
    JanB

    Viewing 1 reply thread
    Author
    Replies
    • #773271

      Hmmm… what is this .Update of which you speak?

      Judging from the code: store the file name, .Update, then re-educate the dialog as to the file name, using .Update flushes everything that was there. So you’re going to have to capture and restore the SaveAs format, too. Maybe like this:

      Dim strFileName As String, lngFormat As Long
      With Dialogs(wdDialogFileSaveAs)
          If .Display = -1 Then
              strFileName = .Name
              lngFormat = .Format
              .Update
              .Name = strFileName
              .Format = lngFormat
              .Execute
          End If
      End With

      Hope this helps. Just in case you wonder what else you might be losing, help lists these parameters: “Name, Format, LockAnnot, Password, AddToMru, WritePassword, RecommendReadOnly, EmbedFonts, NativePictureFormat, FormsData, SaveAsAOCELetter, WriteVersion, VersionDesc”

      • #774250

        Thanks for your input, Jefferson, that does the trick!
        I looked for something along that line, but could not find a suitable property for the dialog panel. And when I placed the dot and “f” after Dialogs(wdDialogFileSaveAs) there was no Format property in the list. A hidden feature?

        JanB

        • #774260

          IntelliSense doesn’t know about the specific arguments for dialogs, only the generic ones. You can look up the specific arguments in the online help for Word VBA, they are listed under something like “Built-in Dialog Box Argument Lists”. Unfortunately, only the names of the arguments are listed, without explanation or example.

          • #774277

            Thanks Hans! I found the help item you were referring to. thankyou

            JanB

          • #774278

            Thanks Hans! I found the help item you were referring to. thankyou

            JanB

        • #774261

          IntelliSense doesn’t know about the specific arguments for dialogs, only the generic ones. You can look up the specific arguments in the online help for Word VBA, they are listed under something like “Built-in Dialog Box Argument Lists”. Unfortunately, only the names of the arguments are listed, without explanation or example.

      • #774251

        Thanks for your input, Jefferson, that does the trick!
        I looked for something along that line, but could not find a suitable property for the dialog panel. And when I placed the dot and “f” after Dialogs(wdDialogFileSaveAs) there was no Format property in the list. A hidden feature?

        JanB

    • #773272

      Hmmm… what is this .Update of which you speak?

      Judging from the code: store the file name, .Update, then re-educate the dialog as to the file name, using .Update flushes everything that was there. So you’re going to have to capture and restore the SaveAs format, too. Maybe like this:

      Dim strFileName As String, lngFormat As Long
      With Dialogs(wdDialogFileSaveAs)
          If .Display = -1 Then
              strFileName = .Name
              lngFormat = .Format
              .Update
              .Name = strFileName
              .Format = lngFormat
              .Execute
          End If
      End With

      Hope this helps. Just in case you wonder what else you might be losing, help lists these parameters: “Name, Format, LockAnnot, Password, AddToMru, WritePassword, RecommendReadOnly, EmbedFonts, NativePictureFormat, FormsData, SaveAsAOCELetter, WriteVersion, VersionDesc”

    Viewing 1 reply thread
    Reply To: FileSaveAs ‘fix’ causes problem with conversion (Win 98 / Word 97 (both Dutch))

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: