+ Reply to Thread
Results 1 to 5 of 5

Hlep with code referencing an addin file.

  1. #1
    KimberlyC
    Guest

    Hlep with code referencing an addin file.

    Hi,
    I'm using the following code to add 4 worksheets from another worksheet to
    the active workbook.
    It works great..unitl I change the Workbook name to the addin file name of
    "WCAddin.xla"...which is how I need to run that file.
    I get a Run Time Error --Application- defined or object defined error
    message.
    Is this due to me changing the workbook file name to xla vs xls?
    If yes.. how would I rewrite the code to work with the addin file instead?


    Public Sub AddWStoWCTemplate()

    Workbooks("WCAddin.xls").Sheets(Array("Summary", "Adjustments", "Details",
    "Calculations")).Copy After:=ActiveWorkbook.Worksheets(Worksheets.Count)

    With ActiveWorkbook
    For i = .Worksheets.Count To .Worksheets.Count - 3 Step -1
    With Worksheets(i)
    .Range("A1").Formula = .Range("A1").Value
    .Range("A2").Formula = .Range("A2").Value
    .Range("A3").Formula = .Range("A3").Value
    End With
    Next
    End With

    End Sub



  2. #2
    Bob Phillips
    Guest

    Re: Hlep with code referencing an addin file.

    Surely, this is because there is already a file of that name open to Excel,
    so you can't have two.

    --

    HTH

    RP
    (remove nothere from the email address if mailing direct)


    "KimberlyC" <[email protected]> wrote in message
    news:[email protected]...
    > Hi,
    > I'm using the following code to add 4 worksheets from another worksheet to
    > the active workbook.
    > It works great..unitl I change the Workbook name to the addin file name of
    > "WCAddin.xla"...which is how I need to run that file.
    > I get a Run Time Error --Application- defined or object defined error
    > message.
    > Is this due to me changing the workbook file name to xla vs xls?
    > If yes.. how would I rewrite the code to work with the addin file instead?
    >
    >
    > Public Sub AddWStoWCTemplate()
    >
    > Workbooks("WCAddin.xls").Sheets(Array("Summary", "Adjustments", "Details",
    > "Calculations")).Copy After:=ActiveWorkbook.Worksheets(Worksheets.Count)
    >
    > With ActiveWorkbook
    > For i = .Worksheets.Count To .Worksheets.Count - 3 Step -1
    > With Worksheets(i)
    > .Range("A1").Formula = .Range("A1").Value
    > .Range("A2").Formula = .Range("A2").Value
    > .Range("A3").Formula = .Range("A3").Value
    > End With
    > Next
    > End With
    >
    > End Sub
    >
    >




  3. #3
    KimberlyC
    Guest

    Re: Hlep with code referencing an addin file.

    Nope..there is only one WCAddin.xla opened...the WCAddin.xls is not
    opened..and I changed the code to reference WCaddin.xla.

    It's copies the worksheets over just file.. It gets the error message when
    it gets to this part of the code:
    .Range("A1").Formula = .Range("A1").Value




    "Bob Phillips" <[email protected]> wrote in message
    news:[email protected]...
    > Surely, this is because there is already a file of that name open to

    Excel,
    > so you can't have two.
    >
    > --
    >
    > HTH
    >
    > RP
    > (remove nothere from the email address if mailing direct)
    >
    >
    > "KimberlyC" <[email protected]> wrote in message
    > news:[email protected]...
    > > Hi,
    > > I'm using the following code to add 4 worksheets from another worksheet

    to
    > > the active workbook.
    > > It works great..unitl I change the Workbook name to the addin file name

    of
    > > "WCAddin.xla"...which is how I need to run that file.
    > > I get a Run Time Error --Application- defined or object defined error
    > > message.
    > > Is this due to me changing the workbook file name to xla vs xls?
    > > If yes.. how would I rewrite the code to work with the addin file

    instead?
    > >
    > >
    > > Public Sub AddWStoWCTemplate()
    > >
    > > Workbooks("WCAddin.xls").Sheets(Array("Summary", "Adjustments",

    "Details",
    > > "Calculations")).Copy After:=ActiveWorkbook.Worksheets(Worksheets.Count)
    > >
    > > With ActiveWorkbook
    > > For i = .Worksheets.Count To .Worksheets.Count - 3 Step -1
    > > With Worksheets(i)
    > > .Range("A1").Formula = .Range("A1").Value
    > > .Range("A2").Formula = .Range("A2").Value
    > > .Range("A3").Formula = .Range("A3").Value
    > > End With
    > > Next
    > > End With
    > >
    > > End Sub
    > >
    > >

    >
    >




  4. #4
    Bob Phillips
    Guest

    Re: Hlep with code referencing an addin file.

    Whilst I cannot see the point of that line of code (a=a), it doesn't look
    like a problem to me. But what has this got to do with an addin, I don't see
    the link.

    --

    HTH

    RP
    (remove nothere from the email address if mailing direct)


    "KimberlyC" <[email protected]> wrote in message
    news:%[email protected]...
    > Nope..there is only one WCAddin.xla opened...the WCAddin.xls is not
    > opened..and I changed the code to reference WCaddin.xla.
    >
    > It's copies the worksheets over just file.. It gets the error message when
    > it gets to this part of the code:
    > .Range("A1").Formula = .Range("A1").Value
    >
    >
    >
    >
    > "Bob Phillips" <[email protected]> wrote in message
    > news:[email protected]...
    > > Surely, this is because there is already a file of that name open to

    > Excel,
    > > so you can't have two.
    > >
    > > --
    > >
    > > HTH
    > >
    > > RP
    > > (remove nothere from the email address if mailing direct)
    > >
    > >
    > > "KimberlyC" <[email protected]> wrote in message
    > > news:[email protected]...
    > > > Hi,
    > > > I'm using the following code to add 4 worksheets from another

    worksheet
    > to
    > > > the active workbook.
    > > > It works great..unitl I change the Workbook name to the addin file

    name
    > of
    > > > "WCAddin.xla"...which is how I need to run that file.
    > > > I get a Run Time Error --Application- defined or object defined error
    > > > message.
    > > > Is this due to me changing the workbook file name to xla vs xls?
    > > > If yes.. how would I rewrite the code to work with the addin file

    > instead?
    > > >
    > > >
    > > > Public Sub AddWStoWCTemplate()
    > > >
    > > > Workbooks("WCAddin.xls").Sheets(Array("Summary", "Adjustments",

    > "Details",
    > > > "Calculations")).Copy

    After:=ActiveWorkbook.Worksheets(Worksheets.Count)
    > > >
    > > > With ActiveWorkbook
    > > > For i = .Worksheets.Count To .Worksheets.Count - 3 Step -1
    > > > With Worksheets(i)
    > > > .Range("A1").Formula = .Range("A1").Value
    > > > .Range("A2").Formula = .Range("A2").Value
    > > > .Range("A3").Formula = .Range("A3").Value
    > > > End With
    > > > Next
    > > > End With
    > > >
    > > > End Sub
    > > >
    > > >

    > >
    > >

    >
    >




  5. #5
    KimberlyC
    Guest

    Re: Hlep with code referencing an addin file.

    When I run the code..it's coping the worksheets from addin file and placing
    them into the activeworkbook.
    Then...the code is changing a cell on each worksheet from text to a formula.
    Anyway.... I have fixed it..and don't really know how
    :-).....I recreated the addin file with new worksheets and copied the code
    over to it....and ...that seemed to fix the problem..

    Thank you for your help!!


    "Bob Phillips" <[email protected]> wrote in message
    news:[email protected]...
    > Whilst I cannot see the point of that line of code (a=a), it doesn't look
    > like a problem to me. But what has this got to do with an addin, I don't

    see
    > the link.
    >
    > --
    >
    > HTH
    >
    > RP
    > (remove nothere from the email address if mailing direct)
    >
    >
    > "KimberlyC" <[email protected]> wrote in message
    > news:%[email protected]...
    > > Nope..there is only one WCAddin.xla opened...the WCAddin.xls is not
    > > opened..and I changed the code to reference WCaddin.xla.
    > >
    > > It's copies the worksheets over just file.. It gets the error message

    when
    > > it gets to this part of the code:
    > > .Range("A1").Formula = .Range("A1").Value
    > >
    > >
    > >
    > >
    > > "Bob Phillips" <[email protected]> wrote in message
    > > news:[email protected]...
    > > > Surely, this is because there is already a file of that name open to

    > > Excel,
    > > > so you can't have two.
    > > >
    > > > --
    > > >
    > > > HTH
    > > >
    > > > RP
    > > > (remove nothere from the email address if mailing direct)
    > > >
    > > >
    > > > "KimberlyC" <[email protected]> wrote in message
    > > > news:[email protected]...
    > > > > Hi,
    > > > > I'm using the following code to add 4 worksheets from another

    > worksheet
    > > to
    > > > > the active workbook.
    > > > > It works great..unitl I change the Workbook name to the addin file

    > name
    > > of
    > > > > "WCAddin.xla"...which is how I need to run that file.
    > > > > I get a Run Time Error --Application- defined or object defined

    error
    > > > > message.
    > > > > Is this due to me changing the workbook file name to xla vs xls?
    > > > > If yes.. how would I rewrite the code to work with the addin file

    > > instead?
    > > > >
    > > > >
    > > > > Public Sub AddWStoWCTemplate()
    > > > >
    > > > > Workbooks("WCAddin.xls").Sheets(Array("Summary", "Adjustments",

    > > "Details",
    > > > > "Calculations")).Copy

    > After:=ActiveWorkbook.Worksheets(Worksheets.Count)
    > > > >
    > > > > With ActiveWorkbook
    > > > > For i = .Worksheets.Count To .Worksheets.Count - 3 Step -1
    > > > > With Worksheets(i)
    > > > > .Range("A1").Formula = .Range("A1").Value
    > > > > .Range("A2").Formula = .Range("A2").Value
    > > > > .Range("A3").Formula = .Range("A3").Value
    > > > > End With
    > > > > Next
    > > > > End With
    > > > >
    > > > > 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