DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 13 of 13

Thread: word .saveas method fails on Vista target

  1. #1
    Join Date
    Jan 2004
    Posts
    30

    word .saveas method fails on Vista target

    I am attempting to upgrade a VB6 application to write a Word file to local dektop drive. My code looks like:

    Set wrdDoc = wrdApp.Documents.Open ("C:\folder\doc1.doc")
    wrdFileName = "C:\folder\doc2.doc")
    Call wrdDoc.SaveAs (wrdFileName)
    wrdDoc.Close (false)
    .Quit

    I am developing on an XP platform, creating the distribution package using Visual Studio Analyzer 6.0, and installing on a Vista system.

    When I load it on a Vista platform that has had VB6 installed, it works very well. When I load it on 3 Vista platforms that have never had VB6 installed, it fails. The error I get is the exceedingly helpful:

    Method "~" of "~" failed.

    I'm sure .SaveAs is the guilty method because I have inserted msgbox statements to determine where I fall off the tracks.

    The document I'm attempting to write to the local disk appears on screen. If I "manually" use the Word Save As feature, it successfully saves to the disk.

    Could someone suggest what I might look at to resolve this very annoying problem?

    Many thanks ...


  2. #2
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,663
    Are you running as administrator on Vista?

  3. #3
    Join Date
    Jan 2004
    Posts
    30
    The Vista system that works correctly is being run as administrator. The remote system that had the application installed is also being run as administrator; however, I will eventually have to remove administrator privileges from the remote system.

  4. #4
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,663
    Quote Originally Posted by GaryAF View Post
    I will eventually have to remove administrator privileges from the remote system.
    Then I suspect this is what you will have to do
    Quote Originally Posted by GaryAF View Post
    The document I'm attempting to write to the local disk appears on screen. If I "manually" use the Word Save As feature, it successfully saves to the disk.

  5. #5
    Join Date
    Jan 2004
    Posts
    30
    So you are suggesting I cannot programmatically save a Word document to local hard drive unless the user is logged on as administrator? Being administrator alone does not seem to be the key because I have one of the remote users logged on as admin and I'm getting the same error message.

  6. #6
    Join Date
    Feb 2004
    Location
    Sydney, Australia
    Posts
    498
    Unless you are simplifying what you really want to do (and not supplying full details), this seems to have nothing to do with Word.

    Set wrdDoc = wrdApp.Documents.Open ("C:\folder\doc1.doc")
    wrdFileName = "C:\folder\doc2.doc")
    Call wrdDoc.SaveAs (wrdFileName)
    wrdDoc.Close (false)
    .Quit
    You are just trying to create a copy of doc1.doc and call it doc2.doc - why not just use FileCopy ?

    Greg

  7. #7
    Join Date
    Jan 2004
    Posts
    30
    Good question Greg. The answer is that doc1 is a word document that I open using VB6 code, fill in some fields based on database contents, and then save out to disk under a different name.

    Another way I could approach this is to open doc1 (this part is working for me) and then programmatically perform the equivalent of a Word "Send To." Maybe something like wrdDoc.SendTo?

    If I did it this way, I would want to pre-assign the addressee and be able to create my own subject line.

    Thoughts anyone?

  8. #8
    Join Date
    Jan 2004
    Posts
    30
    I notice that I have the same problem when i try the RoutingSlip method instead of the SaveAs method. Seems that when I build the distribution package on the XP system and install on the Vista system, the word document methods are failing.

    Note: I include msword.olb as part of my distribution package and place the olb in the application folder on teh Vista desktop. I notice that the version of msword.olb that I'm installing on the Vista system comes from the XP Office11 Object Library. Do I need to use a more current version of the msword.olb file on my Vista computers?

  9. #9
    Join Date
    Nov 2003
    Location
    Alameda, CA
    Posts
    1,737
    Quote Originally Posted by GaryAF View Post
    ... I am developing on an XP platform, creating the distribution package using Visual Studio Analyzer 6.0, and installing on a Vista system.

    When I load it on a Vista platform that has had VB6 installed, it works very well. When I load it on 3 Vista platforms that have never had VB6 installed, it fails. The error I get is the exceedingly helpful:

    Method "~" of "~" failed.
    That error is usually caused by either a missing library, or a library that is not compatible. Because there is no information available, the vbruntime just throws a generic error without any names (just the "~") How helpful.

    But I am surprised that you use a code analyzer tool to create the distribution package. Clearly it is not a programming error, if the app runs fine in a computer with Vista and VB already installed, it is an installation issue. Why don't you use the Package and Deployment Wizard, or something a little more sofisticated?
    "There are two ways to write error-free programs. Only the third one works."
    Unknown

  10. #10
    Join Date
    Jan 2004
    Posts
    30
    Thanks for the feedback.

    Addressing your first point, am I correct that msword.olb is likely the guilty library that precludes .saveas and .routingslip from working on Vista when built on XP?

    On your second point, we've been using Microsoft Development Environment 6.0 to build an installation disk for the last 4 or 5 years. When I install on the target desktop, it places the executable and all associated libraries in the target application folder. It's worked very well up until now.

  11. #11
    Join Date
    Nov 2003
    Location
    Alameda, CA
    Posts
    1,737
    I cannot tell you where the problem is, it can be either there or in any other library that that msword.olb uses, this is why I said that you need a good installer. The MDE 6.0 was working before you start installing on Vista, but 6.0 does not know anything about Vista.

    I can only tell you this: you have a huge company here a lot of developers have and are having the same problems, both with Vista and W7, unfortunately there is no a common cure, every problem is solved case by case.
    In my case, we have always used an INF file and a custom Setup application to install our software, that we build with XP and that get installed and runs fine in both Vista and W7.

    I am really sorry, but I cannot help you more than this (not because I don't want to)
    I wish you good luck, my friend.
    "There are two ways to write error-free programs. Only the third one works."
    Unknown

  12. #12
    Join Date
    Jan 2004
    Posts
    30

    Thumbs up Problem Solved

    Turns out that I had Office 2003 loaded on my XP development system and Office 2007 loaded on my target desktops. I removed 2003 from the XP platform and installed 2007. I then made sure the msword.olb and msoutlook.olb files that I referenced were in the Office12 folder (i.e., the 2007 version). Additionally, I ended up automating outlook from my VB6 code to create the message and attach the document instead of automating Word as expertly described at http://word.mvps.org/FAQs/InterDev/SendMail.htm

    Thanks for the suggestions ...

  13. #13
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,663
    Quote Originally Posted by GaryAF View Post
    Thanks for the suggestions ...
    Thanks for posting your solution.

Similar Threads

  1. Using "Close" reserved word as method name
    By Tim Hick in forum VB Classic
    Replies: 2
    Last Post: 08-03-2002, 03:39 AM
  2. load method fails
    By Mehdi Mousavi in forum XML
    Replies: 2
    Last Post: 05-21-2002, 03:39 PM
  3. Lunch Word VB method from java
    By Franck in forum Java
    Replies: 0
    Last Post: 04-30-2001, 07:49 AM
  4. Replies: 3
    Last Post: 04-13-2001, 09:13 PM
  5. private and static
    By Mark in forum Java
    Replies: 3
    Last Post: 06-09-2000, 08:18 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center