+ Reply to Thread
Results 1 to 3 of 3

wordart

  1. #1
    Shawn G.
    Guest

    wordart

    why does the following code work unless called by a form??? I have a form
    that calls the routine but always gives the error 1004 application or object
    not defined error, BUT if you step thriough the code it works perfectly with
    no error. Any help?
    on error resume next only skips the code.

    Public Sub sendtotest() 'strStr1 As String, strStr2 As String)
    Dim strString1 As String
    Dim strString2 As String
    strString1 = "DCH1205" 'worksheet name
    strString2 = "Why can't I get this to WORK!!!"
    Call test(strString1, strString2)
    End Sub


    Public Sub test(strString1 As String, strString2 As String)
    Dim strText As String
    Dim strworksheet As String
    strText = strString2
    strworksheet = strString1
    Set myDocument = Worksheets(strworksheet)
    Set newWordArt = myDocument.Shapes.AddTextEffect( _
    PresetTextEffect:=msoTextEffect28, Text:=strText, _
    FontName:="Impact", FontSize:=36, _
    FontBold:=msoFalse, FontItalic:=msoFalse, Left:=10, _
    Top:=10)
    End Sub



  2. #2
    sebastienm
    Guest

    RE: wordart

    Hi,
    your code works fine for me whether i run SendToTest directly or from the
    click of a button in a userform, whether the referenced sheet is the
    activesheet or not.

    --
    Regards,
    Sébastien
    <http://www.ondemandanalysis.com>


    "Shawn G." wrote:

    > why does the following code work unless called by a form??? I have a form
    > that calls the routine but always gives the error 1004 application or object
    > not defined error, BUT if you step thriough the code it works perfectly with
    > no error. Any help?
    > on error resume next only skips the code.
    >
    > Public Sub sendtotest() 'strStr1 As String, strStr2 As String)
    > Dim strString1 As String
    > Dim strString2 As String
    > strString1 = "DCH1205" 'worksheet name
    > strString2 = "Why can't I get this to WORK!!!"
    > Call test(strString1, strString2)
    > End Sub
    >
    >
    > Public Sub test(strString1 As String, strString2 As String)
    > Dim strText As String
    > Dim strworksheet As String
    > strText = strString2
    > strworksheet = strString1
    > Set myDocument = Worksheets(strworksheet)
    > Set newWordArt = myDocument.Shapes.AddTextEffect( _
    > PresetTextEffect:=msoTextEffect28, Text:=strText, _
    > FontName:="Impact", FontSize:=36, _
    > FontBold:=msoFalse, FontItalic:=msoFalse, Left:=10, _
    > Top:=10)
    > End Sub
    >
    >


  3. #3
    Shawn G.
    Guest

    RE: wordart

    Your right, it works. EXCEPT in my project!!!!!!! ARRRRGGGGGHHHH!
    Any clue what might be causeing that error, OR a way to bypass the error so
    the user doesn't see it???

    "sebastienm" wrote:

    > Hi,
    > your code works fine for me whether i run SendToTest directly or from the
    > click of a button in a userform, whether the referenced sheet is the
    > activesheet or not.
    >
    > --
    > Regards,
    > Sébastien
    > <http://www.ondemandanalysis.com>
    >
    >
    > "Shawn G." wrote:
    >
    > > why does the following code work unless called by a form??? I have a form
    > > that calls the routine but always gives the error 1004 application or object
    > > not defined error, BUT if you step thriough the code it works perfectly with
    > > no error. Any help?
    > > on error resume next only skips the code.
    > >
    > > Public Sub sendtotest() 'strStr1 As String, strStr2 As String)
    > > Dim strString1 As String
    > > Dim strString2 As String
    > > strString1 = "DCH1205" 'worksheet name
    > > strString2 = "Why can't I get this to WORK!!!"
    > > Call test(strString1, strString2)
    > > End Sub
    > >
    > >
    > > Public Sub test(strString1 As String, strString2 As String)
    > > Dim strText As String
    > > Dim strworksheet As String
    > > strText = strString2
    > > strworksheet = strString1
    > > Set myDocument = Worksheets(strworksheet)
    > > Set newWordArt = myDocument.Shapes.AddTextEffect( _
    > > PresetTextEffect:=msoTextEffect28, Text:=strText, _
    > > FontName:="Impact", FontSize:=36, _
    > > FontBold:=msoFalse, FontItalic:=msoFalse, Left:=10, _
    > > Top:=10)
    > > End Sub
    > >
    > >


+ 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