1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Run-Time Error '91': Object variable or With block variable not set

Discussion in 'C#' started by gray d' newbie, Jul 29, 2008.

  1. #1
    Greetings All,

    Actually this is a VB error, but I have no idea where else I can post in this forum. Sorry about this. Below is my code and it generates error upon execution. The error message is "Run-Time Error '91': Object variable or With block variable not set"

    I actually have this code in my VB app called print.exe, which I place in the server. The strange thing is if my TargetFolder is pointing to my local folder in my desktop (not in the server), it works without throwing me the error message. But if my TargetFolder is "printdocs" which is the folder located in the server together with the print.exe, it return me the error message upon execution, which pointed at the line I bolded below. For your information I already granted full control for the print.exe.

    Private Sub Form_Load()
    TargetFolder = "printdocs\"
    Set objShell = CreateObject("Shell.Application")
    Set objFolder = objShell.Namespace(TargetFolder)
    Set colItems = objFolder.Items
    For Each objItem In colItems
    objItem.InvokeVerbEx ("Print")
    Next
    End Sub

    Thank you very much

    Best Regards
    Gray d' Newbie
     
    gray d' newbie, Jul 29, 2008 IP
  2. chrisn

    chrisn Peon

    Messages:
    54
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    TargetFolder = "printdocs\"

    Is this a real valid path, have you tested the code with a full path ?

    Are you using the exact same TargetFolder = "printdocs\" on your local machine?
     
    chrisn, Aug 5, 2008 IP
  3. Sleeping Troll

    Sleeping Troll Peon

    Messages:
    217
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Some servers inerpret a \ as indicating a literal path, try / instead.
     
    Sleeping Troll, Aug 5, 2008 IP
  4. gray d' newbie

    gray d' newbie Peon

    Messages:
    15
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Thank you everyone for your help. My bad. I should use full path for the TargetFolder. Now the code is running smooth. Thank you very much.

    Best Regards
    Gray d' Newbie
     
    gray d' newbie, Aug 10, 2008 IP