Can't execute macro - Error '76' path not found












0















I'm not really familiar with VB macros. I keep getting




error '76' path not found.




Below is a sample of the code. The thing is we have a file with a macro that is going to sit on a synced OneDrive location. The OneDrive location unfortunately depend's on the user's profile. I tried %username% but it won't work unless I indicate my exact username. This is not what I want as multiple users will be using the macro-enabled file from their respective OneDrive locations. Any ideas?



Sub Export_XML()

Dim r As Range
Dim output As String

For Each r In Range("XML_Output").Rows
output = output & r.Value & vbNewLine
Next r

Open "C:Users%username%Brand Developers LimitedMedia Scheduling - 9. SpreeTVSpree.xml" For Output As #1
Print #1, output
Close

MsgBox "Spree schedule export complete"

End Sub









share|improve this question




















  • 3





    Excel doesn't know anyting about %username%. You need to expand that yourself and use the actual path. A search for how to Get environmental variables in VBA should help.

    – Ken White
    Nov 15 '18 at 3:58


















0















I'm not really familiar with VB macros. I keep getting




error '76' path not found.




Below is a sample of the code. The thing is we have a file with a macro that is going to sit on a synced OneDrive location. The OneDrive location unfortunately depend's on the user's profile. I tried %username% but it won't work unless I indicate my exact username. This is not what I want as multiple users will be using the macro-enabled file from their respective OneDrive locations. Any ideas?



Sub Export_XML()

Dim r As Range
Dim output As String

For Each r In Range("XML_Output").Rows
output = output & r.Value & vbNewLine
Next r

Open "C:Users%username%Brand Developers LimitedMedia Scheduling - 9. SpreeTVSpree.xml" For Output As #1
Print #1, output
Close

MsgBox "Spree schedule export complete"

End Sub









share|improve this question




















  • 3





    Excel doesn't know anyting about %username%. You need to expand that yourself and use the actual path. A search for how to Get environmental variables in VBA should help.

    – Ken White
    Nov 15 '18 at 3:58
















0












0








0








I'm not really familiar with VB macros. I keep getting




error '76' path not found.




Below is a sample of the code. The thing is we have a file with a macro that is going to sit on a synced OneDrive location. The OneDrive location unfortunately depend's on the user's profile. I tried %username% but it won't work unless I indicate my exact username. This is not what I want as multiple users will be using the macro-enabled file from their respective OneDrive locations. Any ideas?



Sub Export_XML()

Dim r As Range
Dim output As String

For Each r In Range("XML_Output").Rows
output = output & r.Value & vbNewLine
Next r

Open "C:Users%username%Brand Developers LimitedMedia Scheduling - 9. SpreeTVSpree.xml" For Output As #1
Print #1, output
Close

MsgBox "Spree schedule export complete"

End Sub









share|improve this question
















I'm not really familiar with VB macros. I keep getting




error '76' path not found.




Below is a sample of the code. The thing is we have a file with a macro that is going to sit on a synced OneDrive location. The OneDrive location unfortunately depend's on the user's profile. I tried %username% but it won't work unless I indicate my exact username. This is not what I want as multiple users will be using the macro-enabled file from their respective OneDrive locations. Any ideas?



Sub Export_XML()

Dim r As Range
Dim output As String

For Each r In Range("XML_Output").Rows
output = output & r.Value & vbNewLine
Next r

Open "C:Users%username%Brand Developers LimitedMedia Scheduling - 9. SpreeTVSpree.xml" For Output As #1
Print #1, output
Close

MsgBox "Spree schedule export complete"

End Sub






excel vba excel-vba






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 15 '18 at 3:47









BigBen

6,3172618




6,3172618










asked Nov 15 '18 at 3:32









Terri Pilares-MagnoTerri Pilares-Magno

82




82








  • 3





    Excel doesn't know anyting about %username%. You need to expand that yourself and use the actual path. A search for how to Get environmental variables in VBA should help.

    – Ken White
    Nov 15 '18 at 3:58
















  • 3





    Excel doesn't know anyting about %username%. You need to expand that yourself and use the actual path. A search for how to Get environmental variables in VBA should help.

    – Ken White
    Nov 15 '18 at 3:58










3




3





Excel doesn't know anyting about %username%. You need to expand that yourself and use the actual path. A search for how to Get environmental variables in VBA should help.

– Ken White
Nov 15 '18 at 3:58







Excel doesn't know anyting about %username%. You need to expand that yourself and use the actual path. A search for how to Get environmental variables in VBA should help.

– Ken White
Nov 15 '18 at 3:58














1 Answer
1






active

oldest

votes


















0














This way:



Open "C:Users" & environ("username") & "Brand Developers LimitedMedia Scheduling - 9. SpreeTVSpree.xml" For Output As #1





share|improve this answer
























  • Thank you! This actually worked for me.

    – Terri Pilares-Magno
    Nov 18 '18 at 23:51











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
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53312039%2fcant-execute-macro-error-76-path-not-found%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














This way:



Open "C:Users" & environ("username") & "Brand Developers LimitedMedia Scheduling - 9. SpreeTVSpree.xml" For Output As #1





share|improve this answer
























  • Thank you! This actually worked for me.

    – Terri Pilares-Magno
    Nov 18 '18 at 23:51
















0














This way:



Open "C:Users" & environ("username") & "Brand Developers LimitedMedia Scheduling - 9. SpreeTVSpree.xml" For Output As #1





share|improve this answer
























  • Thank you! This actually worked for me.

    – Terri Pilares-Magno
    Nov 18 '18 at 23:51














0












0








0







This way:



Open "C:Users" & environ("username") & "Brand Developers LimitedMedia Scheduling - 9. SpreeTVSpree.xml" For Output As #1





share|improve this answer













This way:



Open "C:Users" & environ("username") & "Brand Developers LimitedMedia Scheduling - 9. SpreeTVSpree.xml" For Output As #1






share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 15 '18 at 9:23









AcsErnoAcsErno

869137




869137













  • Thank you! This actually worked for me.

    – Terri Pilares-Magno
    Nov 18 '18 at 23:51



















  • Thank you! This actually worked for me.

    – Terri Pilares-Magno
    Nov 18 '18 at 23:51

















Thank you! This actually worked for me.

– Terri Pilares-Magno
Nov 18 '18 at 23:51





Thank you! This actually worked for me.

– Terri Pilares-Magno
Nov 18 '18 at 23:51




















draft saved

draft discarded




















































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.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53312039%2fcant-execute-macro-error-76-path-not-found%23new-answer', 'question_page');
}
);

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







Popular posts from this blog

Florida Star v. B. J. F.

Error while running script in elastic search , gateway timeout

Adding quotations to stringified JSON object values