+ Reply to Thread
Results 1 to 8 of 8

Object variable or with block variable not set

Hybrid View

  1. #1
    Piotr
    Guest

    Object variable or with block variable not set

    Hi,
    I have this problem every time I try to code anything more complicated
    than few lines.
    It occurs for example in following code. Im sure the code is right as I
    use exactly same code on my second computer. This must be something in
    excel options or I have no clue ????

    Dim PathWinZip As String, FileNameZip As String, FileNameXls As
    String
    Dim ShellStr As String, strDate As String
    Dim OutApp As Object
    Dim OutMail As Object



    PathWinZip = "C:\program files\7-zip\"
    'This will check if this is the path where WinZip is installed.
    If Dir(PathWinZip & "7z.exe") = "" Then
    MsgBox "Please find your copy of winzip32.exe and try again"
    Exit Sub
    End If

    ' Build the date/Time string
    strDate = Format(Now, "dd-mm-yy h-mm-ss")
    Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.CreateItem(0)
    <<<<<------------------------------error here
    With OutMail


  2. #2
    Bob Phillips
    Guest

    Re: Object variable or with block variable not set

    Do you have Outlook installed? You should check that the CreateObject action
    is successful before ploughing on.

    --
    HTH

    Bob Phillips

    (remove nothere from email address if mailing direct)

    "Piotr" <hokah@wp.pl> wrote in message
    news:1134992230.002838.136130@g43g2000cwa.googlegroups.com...
    > Hi,
    > I have this problem every time I try to code anything more complicated
    > than few lines.
    > It occurs for example in following code. Im sure the code is right as I
    > use exactly same code on my second computer. This must be something in
    > excel options or I have no clue ????
    >
    > Dim PathWinZip As String, FileNameZip As String, FileNameXls As
    > String
    > Dim ShellStr As String, strDate As String
    > Dim OutApp As Object
    > Dim OutMail As Object
    >
    >
    >
    > PathWinZip = "C:\program files\7-zip\"
    > 'This will check if this is the path where WinZip is installed.
    > If Dir(PathWinZip & "7z.exe") = "" Then
    > MsgBox "Please find your copy of winzip32.exe and try again"
    > Exit Sub
    > End If
    >
    > ' Build the date/Time string
    > strDate = Format(Now, "dd-mm-yy h-mm-ss")
    > Set OutApp = CreateObject("Outlook.Application")
    > Set OutMail = OutApp.CreateItem(0)
    > <<<<<------------------------------error here
    > With OutMail
    >




  3. #3
    Piotr
    Guest

    Re: Object variable or with block variable not set

    Yes I do have Outlook, but i dont know how to check if the CreateObject
    is successful.


  4. #4
    Dave Peterson
    Guest

    Re: Object variable or with block variable not set

    Set OutApp = nothing
    on error resume next
    Set OutApp = CreateObject("Outlook.Application")
    on error goto 0

    if outapp is nothing then
    'something very bad happened
    else
    'it worked ok
    end if



    Piotr wrote:
    >
    > Yes I do have Outlook, but i dont know how to check if the CreateObject
    > is successful.


    --

    Dave Peterson

  5. #5
    Piotr
    Guest

    Re: Object variable or with block variable not set

    Unfortunatly CreateObject("Outlook.Application") failed no idea ...


  6. #6
    Bob Phillips
    Guest

    Re: Object variable or with block variable not set

    What error? Do you want to post the workbook at www.cjoint.com to look?

    --
    HTH

    Bob Phillips

    (remove nothere from email address if mailing direct)

    "Piotr" <hokah@wp.pl> wrote in message
    news:1135152843.332622.39060@f14g2000cwb.googlegroups.com...
    > Unfortunatly CreateObject("Outlook.Application") failed no idea ...
    >




  7. #7
    Dave Peterson
    Guest

    Re: Object variable or with block variable not set

    Maybe this would give a hint:

    Set OutApp = Nothing
    On Error Resume Next
    Set OutApp = CreateObject("Outlook.Application")
    If Err.Number <> 0 Then
    MsgBox Err.Number & vbLf & Err.Description
    Err.Clear
    End If
    On Error GoTo 0

    Piotr wrote:
    >
    > Unfortunatly CreateObject("Outlook.Application") failed no idea ...


    --

    Dave Peterson

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1