Reference in Excel VBA code does not work the first time program is startedHow to pause for specific amount of time? (Excel/VBA)MSXML2.DOMDocument60 crashes ExcelExcel Addins and Extra Driversexcel replace function in access vbaExecute AutoIt and wait for finishExcel VBA reference for Inet objectsVBA Calling C++ DLL - error 48 (file not found)OneNote2013-Reference to undeclared namespace prefix:'one' errormsxml2.xmlhttp IE 11 vs ChromeExcel stops responding while executing loop
How to plan the font size in a fiction?
Single level file directory
How do I tell the reader that my character is autistic in Fantasy?
Who voices the character "Finger" in The Fifth Element?
Different budgets within roommate group
Was it really unprofessional of me to leave without asking for a raise first?
How to properly say asset/assets in German
Why was Mal so quick to drop Bester in favour of Kaylee?
Warnings of R. Chaim Vital
What do you call a notepad used to keep a record?
Why did NASA wet the road in front of the Space Shuttle crawler?
Losing queen and then winning the game
How to define a macro inside a macro via if?
What kind of jet plane is this?
Golf the smallest circle!
Can European countries bypass the EU and make their own individual trade deal with the U.S.?
Do the 26 richest billionaires own as much wealth as the poorest 3.8 billion people?
What does grep -v "grep" mean and do?
Is there any way to adjust the component values to get 5V output?
sorting 4 numbers using Min - Max boxes
How do I ensure my employees don't abuse my flexible work hours policy?
Is is okay to submit a paper from a master's thesis without informing the advisor?
How did Lefschetz do mathematics without hands?
How receiver knows the exact frequency in the channel to "listen to"?
Reference in Excel VBA code does not work the first time program is started
How to pause for specific amount of time? (Excel/VBA)MSXML2.DOMDocument60 crashes ExcelExcel Addins and Extra Driversexcel replace function in access vbaExecute AutoIt and wait for finishExcel VBA reference for Inet objectsVBA Calling C++ DLL - error 48 (file not found)OneNote2013-Reference to undeclared namespace prefix:'one' errormsxml2.xmlhttp IE 11 vs ChromeExcel stops responding while executing loop
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I do some coding of Excel AddIns (using Excel 2016), which have to be used by another user (using Excel 365), too.
In order to manipulate XML, I added the reference to Microsoft XML, v6.0; everything works perfectly fine on my machine.
Running the code on the other user's machine shows that the reference is not checked (although the underyling dll is available at the expected file location).
I added some code to programmatically add the reference (no error handling yet):
Sub AddXmlReference()
Dim ref As Reference
Dim existRef As Boolean
existRef = False
For Each ref In Application.VBE.ActiveVBProject.References
If ref.Name = "MSXML2" Then
existRef = True
End If
Next ref
If existRef = False Then
Application.VBE.ActiveVBProject.References.AddFromFile "C:WindowsSysWOW64msxml6.dll"
End If
End Sub
Starting the program on the other user's machine shows some behaviour I do not understand (and I could not find anything helpful):
The first time the program is executed, it runs into an error (user defined error at the module that tries to manipulate XML); thereafter, the program works nicely. If I close excel and restart, the same behaviour starts again. Summarizing, it looks like:
Excel does not store the reference (which in a way is understandable, as the underlying code dercertain reasons is is opened read-only; in a way however it is not, as the underlying code does have the reference)
Whilst running the code, the added reference cannot be used
Within one excel session, the reference is stored
Is there a way to make this added reference being stored permanently? Or did I miss something out?
excel vba
|
show 12 more comments
I do some coding of Excel AddIns (using Excel 2016), which have to be used by another user (using Excel 365), too.
In order to manipulate XML, I added the reference to Microsoft XML, v6.0; everything works perfectly fine on my machine.
Running the code on the other user's machine shows that the reference is not checked (although the underyling dll is available at the expected file location).
I added some code to programmatically add the reference (no error handling yet):
Sub AddXmlReference()
Dim ref As Reference
Dim existRef As Boolean
existRef = False
For Each ref In Application.VBE.ActiveVBProject.References
If ref.Name = "MSXML2" Then
existRef = True
End If
Next ref
If existRef = False Then
Application.VBE.ActiveVBProject.References.AddFromFile "C:WindowsSysWOW64msxml6.dll"
End If
End Sub
Starting the program on the other user's machine shows some behaviour I do not understand (and I could not find anything helpful):
The first time the program is executed, it runs into an error (user defined error at the module that tries to manipulate XML); thereafter, the program works nicely. If I close excel and restart, the same behaviour starts again. Summarizing, it looks like:
Excel does not store the reference (which in a way is understandable, as the underlying code dercertain reasons is is opened read-only; in a way however it is not, as the underlying code does have the reference)
Whilst running the code, the added reference cannot be used
Within one excel session, the reference is stored
Is there a way to make this added reference being stored permanently? Or did I miss something out?
excel vba
2
Until recently the default installation of Office 365 was 32 bit. What version does your user have, 32 or 64 bit.
– Freeflow
Mar 25 at 14:16
1
Have you trusted access to the VBA Project Object Model from Macro Settings?
– Foxfire And Burns And Burns
Mar 25 at 14:18
2
Actually the references are added to a specific file not to Excel, so if you save that file after the reference was added the reference should be stored permanently. So if your file is an add-in you need to save that add-in. • Alternatively use LateBinding instead of EarlyBinding to avoid that references need to be added at all.
– Pᴇʜ
Mar 25 at 14:19
1
PEH says it and I think it's important to know what Early and Late Binding mean and to understand the differences..
– user2261597
Mar 25 at 14:24
2
References are workbook-specific as has been said. It is not possible for the same workbook to have different references set.
– Rory
Mar 25 at 15:18
|
show 12 more comments
I do some coding of Excel AddIns (using Excel 2016), which have to be used by another user (using Excel 365), too.
In order to manipulate XML, I added the reference to Microsoft XML, v6.0; everything works perfectly fine on my machine.
Running the code on the other user's machine shows that the reference is not checked (although the underyling dll is available at the expected file location).
I added some code to programmatically add the reference (no error handling yet):
Sub AddXmlReference()
Dim ref As Reference
Dim existRef As Boolean
existRef = False
For Each ref In Application.VBE.ActiveVBProject.References
If ref.Name = "MSXML2" Then
existRef = True
End If
Next ref
If existRef = False Then
Application.VBE.ActiveVBProject.References.AddFromFile "C:WindowsSysWOW64msxml6.dll"
End If
End Sub
Starting the program on the other user's machine shows some behaviour I do not understand (and I could not find anything helpful):
The first time the program is executed, it runs into an error (user defined error at the module that tries to manipulate XML); thereafter, the program works nicely. If I close excel and restart, the same behaviour starts again. Summarizing, it looks like:
Excel does not store the reference (which in a way is understandable, as the underlying code dercertain reasons is is opened read-only; in a way however it is not, as the underlying code does have the reference)
Whilst running the code, the added reference cannot be used
Within one excel session, the reference is stored
Is there a way to make this added reference being stored permanently? Or did I miss something out?
excel vba
I do some coding of Excel AddIns (using Excel 2016), which have to be used by another user (using Excel 365), too.
In order to manipulate XML, I added the reference to Microsoft XML, v6.0; everything works perfectly fine on my machine.
Running the code on the other user's machine shows that the reference is not checked (although the underyling dll is available at the expected file location).
I added some code to programmatically add the reference (no error handling yet):
Sub AddXmlReference()
Dim ref As Reference
Dim existRef As Boolean
existRef = False
For Each ref In Application.VBE.ActiveVBProject.References
If ref.Name = "MSXML2" Then
existRef = True
End If
Next ref
If existRef = False Then
Application.VBE.ActiveVBProject.References.AddFromFile "C:WindowsSysWOW64msxml6.dll"
End If
End Sub
Starting the program on the other user's machine shows some behaviour I do not understand (and I could not find anything helpful):
The first time the program is executed, it runs into an error (user defined error at the module that tries to manipulate XML); thereafter, the program works nicely. If I close excel and restart, the same behaviour starts again. Summarizing, it looks like:
Excel does not store the reference (which in a way is understandable, as the underlying code dercertain reasons is is opened read-only; in a way however it is not, as the underlying code does have the reference)
Whilst running the code, the added reference cannot be used
Within one excel session, the reference is stored
Is there a way to make this added reference being stored permanently? Or did I miss something out?
excel vba
excel vba
edited Mar 25 at 14:17
Pᴇʜ
28.1k6 gold badges30 silver badges54 bronze badges
28.1k6 gold badges30 silver badges54 bronze badges
asked Mar 25 at 14:09
alexanderalexander
208 bronze badges
208 bronze badges
2
Until recently the default installation of Office 365 was 32 bit. What version does your user have, 32 or 64 bit.
– Freeflow
Mar 25 at 14:16
1
Have you trusted access to the VBA Project Object Model from Macro Settings?
– Foxfire And Burns And Burns
Mar 25 at 14:18
2
Actually the references are added to a specific file not to Excel, so if you save that file after the reference was added the reference should be stored permanently. So if your file is an add-in you need to save that add-in. • Alternatively use LateBinding instead of EarlyBinding to avoid that references need to be added at all.
– Pᴇʜ
Mar 25 at 14:19
1
PEH says it and I think it's important to know what Early and Late Binding mean and to understand the differences..
– user2261597
Mar 25 at 14:24
2
References are workbook-specific as has been said. It is not possible for the same workbook to have different references set.
– Rory
Mar 25 at 15:18
|
show 12 more comments
2
Until recently the default installation of Office 365 was 32 bit. What version does your user have, 32 or 64 bit.
– Freeflow
Mar 25 at 14:16
1
Have you trusted access to the VBA Project Object Model from Macro Settings?
– Foxfire And Burns And Burns
Mar 25 at 14:18
2
Actually the references are added to a specific file not to Excel, so if you save that file after the reference was added the reference should be stored permanently. So if your file is an add-in you need to save that add-in. • Alternatively use LateBinding instead of EarlyBinding to avoid that references need to be added at all.
– Pᴇʜ
Mar 25 at 14:19
1
PEH says it and I think it's important to know what Early and Late Binding mean and to understand the differences..
– user2261597
Mar 25 at 14:24
2
References are workbook-specific as has been said. It is not possible for the same workbook to have different references set.
– Rory
Mar 25 at 15:18
2
2
Until recently the default installation of Office 365 was 32 bit. What version does your user have, 32 or 64 bit.
– Freeflow
Mar 25 at 14:16
Until recently the default installation of Office 365 was 32 bit. What version does your user have, 32 or 64 bit.
– Freeflow
Mar 25 at 14:16
1
1
Have you trusted access to the VBA Project Object Model from Macro Settings?
– Foxfire And Burns And Burns
Mar 25 at 14:18
Have you trusted access to the VBA Project Object Model from Macro Settings?
– Foxfire And Burns And Burns
Mar 25 at 14:18
2
2
Actually the references are added to a specific file not to Excel, so if you save that file after the reference was added the reference should be stored permanently. So if your file is an add-in you need to save that add-in. • Alternatively use LateBinding instead of EarlyBinding to avoid that references need to be added at all.
– Pᴇʜ
Mar 25 at 14:19
Actually the references are added to a specific file not to Excel, so if you save that file after the reference was added the reference should be stored permanently. So if your file is an add-in you need to save that add-in. • Alternatively use LateBinding instead of EarlyBinding to avoid that references need to be added at all.
– Pᴇʜ
Mar 25 at 14:19
1
1
PEH says it and I think it's important to know what Early and Late Binding mean and to understand the differences..
– user2261597
Mar 25 at 14:24
PEH says it and I think it's important to know what Early and Late Binding mean and to understand the differences..
– user2261597
Mar 25 at 14:24
2
2
References are workbook-specific as has been said. It is not possible for the same workbook to have different references set.
– Rory
Mar 25 at 15:18
References are workbook-specific as has been said. It is not possible for the same workbook to have different references set.
– Rory
Mar 25 at 15:18
|
show 12 more comments
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55339729%2freference-in-excel-vba-code-does-not-work-the-first-time-program-is-started%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.
Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55339729%2freference-in-excel-vba-code-does-not-work-the-first-time-program-is-started%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
2
Until recently the default installation of Office 365 was 32 bit. What version does your user have, 32 or 64 bit.
– Freeflow
Mar 25 at 14:16
1
Have you trusted access to the VBA Project Object Model from Macro Settings?
– Foxfire And Burns And Burns
Mar 25 at 14:18
2
Actually the references are added to a specific file not to Excel, so if you save that file after the reference was added the reference should be stored permanently. So if your file is an add-in you need to save that add-in. • Alternatively use LateBinding instead of EarlyBinding to avoid that references need to be added at all.
– Pᴇʜ
Mar 25 at 14:19
1
PEH says it and I think it's important to know what Early and Late Binding mean and to understand the differences..
– user2261597
Mar 25 at 14:24
2
References are workbook-specific as has been said. It is not possible for the same workbook to have different references set.
– Rory
Mar 25 at 15:18