1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Open an excel workbook which contain macro from vb

Discussion in 'Business Applications' started by FlossWales, May 19, 2003.

Thread Status:
Not open for further replies.
  1. FlossWales

    FlossWales Thread Starter

    Joined:
    May 19, 2003
    Messages:
    1
    :) Good Day Moderator,
    just got to the core... I've problem to open an excel workbook which contain macros from visual basic at run-time. Thats it, I don't know what properties or method that I should used.

    For your illustration, perhaps I should write some of them in here ( hope you don't getting bored with this ) :)

    dim strFile as String
    dim objExcel as Excel.Application

    strFile = InputBox("Please input your excel file full path :","C:\")

    Set objExcel = CreateObject("Excel.Application")

    With objExcel
    .DisplayAlerts = False
    .Workbooks.Open strFile

    MsgBox "Your name is : " & .ActiveSheet.Range("D1")

    .ActiveWorkbook.Close False
    .Quit
    End With

    While trying to process the Msgbox's function, it said that "Object variable or With block variable not set", just like if the object has not successfully created.

    Do you have any idea with this ? I really don't know what to do.
    Thanks a lot for your help and have a nice day :)

    Best Regards.
     
  2. Anne Troy

    Anne Troy

    Joined:
    Feb 14, 1999
    Messages:
    11,746
    First Name:
    Anne
    I don't claim to do VBA, but I dabble.

    In the first place, if you are creating this code in an Excel file, I don't think you need to declare Excel as the application at all.

    I think you should be creating a workbook object and not an application object.

    I just tried it out, and I get that darn Error 429, but I think that's better than what you're getting.
     
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/134422

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice