Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6551853
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:23:19+00:00 2026-05-25T12:23:19+00:00

I want to run my code when add-in loads. (Open excel file -> load

  • 0

I want to run my code when add-in loads. (Open excel file -> load addin -> run code)

But I have a problem with event handler.

I don’t know what kind of event handler I need use and how to load installed addin.

(I try to use Workbook_open handler but I think it’s wrong)

And I try to use Workbook_AddinInstall() event handler then when the install add-in, it works. But to make work my code, I need to reinstall add-in every time.

And How can I run add-in which already in the add-ins list.

Here is my code,

Private Sub Workbook_AddinInstall()
Dim counter As Long
Dim rowSize As Long
Dim userId As String
Dim answers As String
Dim vals As String

Dim i As Integer

Set currentSheet = ActiveWorkbook.ActiveSheet

MsgBox (currentSheet.Cells(1, 2).Value)

rowSize = currentSheet.Rows.Count
counter = 1


'Create Column

currentSheet.Cells(1, 7).Value = "Country"
currentSheet.Cells(1, 8).Value = "State"
currentSheet.Cells(1, 9).Value = "Age"

currentSheet.Cells(1, 7).Font.Bold = True
currentSheet.Cells(1, 8).Font.Bold = True
currentSheet.Cells(1, 9).Font.Bold = True

currentSheet.Cells(1, 7).HorizontalAlignment = xlCenter
currentSheet.Cells(1, 8).HorizontalAlignment = xlCenter
currentSheet.Cells(1, 9).HorizontalAlignment = xlCenter

currentSheet.Cells(1, 7).Borders().LineStyle = xlContinuous
currentSheet.Cells(1, 8).Borders().LineStyle = xlContinuous
currentSheet.Cells(1, 9).Borders().LineStyle = xlContinuous

'Set Value
Do While counter < rowSize

    If currentSheet.Cells(counter, 1).Value = Null Then Exit Do
    If currentSheet.Cells(counter, 4).Value = "3" Then

        userId = currentSheet.Cells(counter, 2).Value
        vals = currentSheet.Cells(counter, 6).Value
        'MsgBox (vals)

        temp = Split(vals, ",")
        i = 0

        Do While i < 10
            targetCell = counter + i
            If currentSheet.Cells(targetCell, 2).Value = userId Then
               currentSheet.Cells(targetCell, 7).Value = temp(0)
               currentSheet.Cells(targetCell, 8).Value = temp(1)
               currentSheet.Cells(targetCell, 9).Value = temp(2)

               currentSheet.Cells(targetCell, 7).HorizontalAlignment = xlCenter
               currentSheet.Cells(targetCell, 8).HorizontalAlignment = xlCenter
               currentSheet.Cells(targetCell, 9).HorizontalAlignment = xlCenter

               currentSheet.Cells(targetCell, 7).Borders().LineStyle = xlContinuous
               currentSheet.Cells(targetCell, 8).Borders().LineStyle = xlContinuous
               currentSheet.Cells(targetCell, 9).Borders().LineStyle = xlContinuous
            End If
            i = i + 1
        Loop
        temp = Null
       'parsing_question_1(vals, userId)
    End If

    counter = counter + 1
Loop

End Sub

Thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T12:23:19+00:00Added an answer on May 25, 2026 at 12:23 pm

    Create the event in the addin:

    http://www.cpearson.com/excel/appevent.htm

    Also, if you wanted you could do the workbookopen event and just check to make sure the workbook matches the workbook name, or create a hidden worksheet that has a value in cell A1 that tells you if it is your workbook.

    You can also uninstall the add-in every time your workbook closes (using the events again), if that is the route you prefer.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code I want to run, but the problem is $this->type
I want to run some code after loading my custom file, but I want
I have some jQuery/JavaScript code that I want to run only when there is
I have a question concerning this code which I want to run on QNX:
I have the following sample code which doesn't seem to want to run. import
Edit: I solved my problem but if you have anything to add please do.
Why this code don't work,when i want run this code vwd 2008 express show
I want to run the following code: ajaxUpdate(10); With a delay of 1 second
I want code to run whenever I create a new object. For example, see
I want to run the following jquery code on every page in my website.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.