Results 1 to 4 of 4

Thread: Word Problems

  1. #1

    Thread Starter
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538

    Word Problems

    Hi All,

    In project1, I use this to open a word file & run a macro - this works fine in both the vs.net ide for thi project1, and if I compile this to an exe file & call it using the shellexecute api from vb6, no problems whatsoever!

    VB Code:
    1. Dim objWrdApp as Microsoft.Office.Interop.Word.Application _
    2. = new Microsoft.Office.Interop.Word.Application
    3.  
    4. objWrdApp.Documents.Open(CType(strWordFileName, system.object))
    5. objWrdApp.Run (MacroName:="execConvEquations")

    However, calling this from a second - new vb.net project using:
    VB Code:
    1. ProcessVariable "C:\MyCompiledApp", strWordFileNameVariable)

    It comes up with the error Unable to run the specified macro. Can someone tell me how to ressolve this please?!?!?!

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

  2. #2
    PowerPoster
    Join Date
    Dec 2003
    Location
    Bristol, England (but heart is in Virginia)
    Posts
    2,949
    Hi,

    "Dim objWrdApp as Microsoft.Office.Interop.Word.Application _
    = new Microsoft.Office.Interop.Word.Application"

    I don't know much about Macros but I do know you cannot call anything declared as Private from another project. Surely you should declare it as "Public", "Shared" or "Protected"?
    Taxes
    The more I learn about VB.NET the more I like dBaseIII Plus

    The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.

  3. #3

    Thread Starter
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538
    This one's declared within sub Main() of project1 which then gets compiled - so this one's running as a standalone exe.

    I'm then using process.start (more or less like shell, shellexecute in vb6) to open/run this file - I'm not inheriting or calling any of the code direct from my project.

    Thanks for trying though anyhow.

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

  4. #4
    PowerPoster
    Join Date
    Dec 2003
    Location
    Bristol, England (but heart is in Virginia)
    Posts
    2,949
    Hi,

    Totally out of my depth but I have just referred to a manual and could it possibly be that

    "ProcessVariable "C:\MyCompiledApp", strWordFileNameVariable)"

    should be rearranged to

    "ProcessVariable (strWordFileNameVariable, "C:\MyCompiledApp",)


    EDIT:

    I've just noticed that in your posted code

    ProcessVariable "C:\MyCompiledApp", strWordFileNameVariable)

    you have ommitted the first "("
    Taxes
    The more I learn about VB.NET the more I like dBaseIII Plus

    The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.

Posting Permissions

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



Click Here to Expand Forum to Full Width