Download Excel direct to drive (C:) (No save as option require) VBA Excel
I am new in VBA. Please help me to download the excel file direct in to my drive. I have only option to click the element and it prompt of "Save As" dialog box.
Application.StatusBar = "Saving - Dashboard.xlsx"
Set InputElement = doc.querySelector("span.export[class='export excel'")
If Not InputElement Is Nothing Then
InputElement.Click
I am running this code every hour, I can't click save as button every hour.
I was thinking to download auto downloader, but did not get much success. Coz, I have have admin right and out of policy.
Public Sub OpenIE_Login()
Set IE = New InternetExplorer
IE.Visible = True
IE.Navigate cURL
Do While IE.readyState <> READYSTATE_COMPLETE Or IE.Busy: DoEvents: Loop ''' ATTENTION - PAUSE HERE
Set doc = IE.Document
Set LoginForm = doc.forms(0)
Set InputElement = doc.querySelector("input#userName[id='userName']")
If Not InputElement Is Nothing Then
InputElement.Value = cUsername
End If
'
Set InputElement = doc.querySelector("input.field[type='password']")
If Not InputElement Is Nothing Then
InputElement.Value = cPassword
End If
Application.StatusBar = "Saving - WokingHours.xlsx"
Set InputElement = doc.querySelector("span.export[class='export excel'")
'Dim TempStr As String
If Not InputElement Is Nothing Then
'TempStr = InputElement.Value
InputElement.Click
End Sub
download internet-explorer-11
add a comment |
I am new in VBA. Please help me to download the excel file direct in to my drive. I have only option to click the element and it prompt of "Save As" dialog box.
Application.StatusBar = "Saving - Dashboard.xlsx"
Set InputElement = doc.querySelector("span.export[class='export excel'")
If Not InputElement Is Nothing Then
InputElement.Click
I am running this code every hour, I can't click save as button every hour.
I was thinking to download auto downloader, but did not get much success. Coz, I have have admin right and out of policy.
Public Sub OpenIE_Login()
Set IE = New InternetExplorer
IE.Visible = True
IE.Navigate cURL
Do While IE.readyState <> READYSTATE_COMPLETE Or IE.Busy: DoEvents: Loop ''' ATTENTION - PAUSE HERE
Set doc = IE.Document
Set LoginForm = doc.forms(0)
Set InputElement = doc.querySelector("input#userName[id='userName']")
If Not InputElement Is Nothing Then
InputElement.Value = cUsername
End If
'
Set InputElement = doc.querySelector("input.field[type='password']")
If Not InputElement Is Nothing Then
InputElement.Value = cPassword
End If
Application.StatusBar = "Saving - WokingHours.xlsx"
Set InputElement = doc.querySelector("span.export[class='export excel'")
'Dim TempStr As String
If Not InputElement Is Nothing Then
'TempStr = InputElement.Value
InputElement.Click
End Sub
download internet-explorer-11
add a comment |
I am new in VBA. Please help me to download the excel file direct in to my drive. I have only option to click the element and it prompt of "Save As" dialog box.
Application.StatusBar = "Saving - Dashboard.xlsx"
Set InputElement = doc.querySelector("span.export[class='export excel'")
If Not InputElement Is Nothing Then
InputElement.Click
I am running this code every hour, I can't click save as button every hour.
I was thinking to download auto downloader, but did not get much success. Coz, I have have admin right and out of policy.
Public Sub OpenIE_Login()
Set IE = New InternetExplorer
IE.Visible = True
IE.Navigate cURL
Do While IE.readyState <> READYSTATE_COMPLETE Or IE.Busy: DoEvents: Loop ''' ATTENTION - PAUSE HERE
Set doc = IE.Document
Set LoginForm = doc.forms(0)
Set InputElement = doc.querySelector("input#userName[id='userName']")
If Not InputElement Is Nothing Then
InputElement.Value = cUsername
End If
'
Set InputElement = doc.querySelector("input.field[type='password']")
If Not InputElement Is Nothing Then
InputElement.Value = cPassword
End If
Application.StatusBar = "Saving - WokingHours.xlsx"
Set InputElement = doc.querySelector("span.export[class='export excel'")
'Dim TempStr As String
If Not InputElement Is Nothing Then
'TempStr = InputElement.Value
InputElement.Click
End Sub
download internet-explorer-11
I am new in VBA. Please help me to download the excel file direct in to my drive. I have only option to click the element and it prompt of "Save As" dialog box.
Application.StatusBar = "Saving - Dashboard.xlsx"
Set InputElement = doc.querySelector("span.export[class='export excel'")
If Not InputElement Is Nothing Then
InputElement.Click
I am running this code every hour, I can't click save as button every hour.
I was thinking to download auto downloader, but did not get much success. Coz, I have have admin right and out of policy.
Public Sub OpenIE_Login()
Set IE = New InternetExplorer
IE.Visible = True
IE.Navigate cURL
Do While IE.readyState <> READYSTATE_COMPLETE Or IE.Busy: DoEvents: Loop ''' ATTENTION - PAUSE HERE
Set doc = IE.Document
Set LoginForm = doc.forms(0)
Set InputElement = doc.querySelector("input#userName[id='userName']")
If Not InputElement Is Nothing Then
InputElement.Value = cUsername
End If
'
Set InputElement = doc.querySelector("input.field[type='password']")
If Not InputElement Is Nothing Then
InputElement.Value = cPassword
End If
Application.StatusBar = "Saving - WokingHours.xlsx"
Set InputElement = doc.querySelector("span.export[class='export excel'")
'Dim TempStr As String
If Not InputElement Is Nothing Then
'TempStr = InputElement.Value
InputElement.Click
End Sub
download internet-explorer-11
download internet-explorer-11
asked Jan 20 at 3:16
Ravi SharmaRavi Sharma
1
1
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
You did not posted the code which actually downloads the file. In title of the thread, You said VBA Excel but your code using IE object.
If you have the URL of the file than you can refer example below for downloading the file.
Private Declare PtrSafe Function URLDownloadToFile Lib "urlmon" _
Alias "URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, _
ByVal szFileName As String, ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long
Sub demo()
Dim strURL As String
Dim LocalFilePath As String
Dim DownloadStatus As Long
strURL = "http://data.iana.org/TLD/tlds-alpha-by-domain.txt"
LocalFilePath = "C:UserspanchalsDesktopsample.txt"
DownloadStatus = URLDownloadToFile(0, strURL, LocalFilePath, 0, 0)
If DownloadStatus = 0 Then
MsgBox "File Downloaded. Check in this path: " & LocalFilePath
Else
MsgBox "Download File Process Failed"
End If
End Sub
You need to modify the code as per your own requirement.
Reference:
Download Files with VBA URLDownloadToFile
Thank you for the answer!! Like I said, I am new in VBA. The code is in excel flie and when it reach at "InputElement.Click" popup comes and ask to 1.Open, 2 Save & 3 SaveAS. Is possible to save directly in to my drive?
– Ravi Sharma
Jan 22 at 12:25
If you have URL of the file on the time of click than you can use the above code to save the file directly to your drive. it will not show a Save As pop up to you. I suggest you to directly run the sample code to get the idea about it.
– Deepak-MSFT
Jan 23 at 3:26
Thank you for reply, i did same as you suggest but did not get much success. In the link, extension not define (.xls)
– Ravi Sharma
Jan 24 at 8:47
nicetime.com/reports/…
– Ravi Sharma
Jan 24 at 8:50
add a comment |
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%2f54273295%2fdownload-excel-direct-to-drive-c-no-save-as-option-require-vba-excel%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
You did not posted the code which actually downloads the file. In title of the thread, You said VBA Excel but your code using IE object.
If you have the URL of the file than you can refer example below for downloading the file.
Private Declare PtrSafe Function URLDownloadToFile Lib "urlmon" _
Alias "URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, _
ByVal szFileName As String, ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long
Sub demo()
Dim strURL As String
Dim LocalFilePath As String
Dim DownloadStatus As Long
strURL = "http://data.iana.org/TLD/tlds-alpha-by-domain.txt"
LocalFilePath = "C:UserspanchalsDesktopsample.txt"
DownloadStatus = URLDownloadToFile(0, strURL, LocalFilePath, 0, 0)
If DownloadStatus = 0 Then
MsgBox "File Downloaded. Check in this path: " & LocalFilePath
Else
MsgBox "Download File Process Failed"
End If
End Sub
You need to modify the code as per your own requirement.
Reference:
Download Files with VBA URLDownloadToFile
Thank you for the answer!! Like I said, I am new in VBA. The code is in excel flie and when it reach at "InputElement.Click" popup comes and ask to 1.Open, 2 Save & 3 SaveAS. Is possible to save directly in to my drive?
– Ravi Sharma
Jan 22 at 12:25
If you have URL of the file on the time of click than you can use the above code to save the file directly to your drive. it will not show a Save As pop up to you. I suggest you to directly run the sample code to get the idea about it.
– Deepak-MSFT
Jan 23 at 3:26
Thank you for reply, i did same as you suggest but did not get much success. In the link, extension not define (.xls)
– Ravi Sharma
Jan 24 at 8:47
nicetime.com/reports/…
– Ravi Sharma
Jan 24 at 8:50
add a comment |
You did not posted the code which actually downloads the file. In title of the thread, You said VBA Excel but your code using IE object.
If you have the URL of the file than you can refer example below for downloading the file.
Private Declare PtrSafe Function URLDownloadToFile Lib "urlmon" _
Alias "URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, _
ByVal szFileName As String, ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long
Sub demo()
Dim strURL As String
Dim LocalFilePath As String
Dim DownloadStatus As Long
strURL = "http://data.iana.org/TLD/tlds-alpha-by-domain.txt"
LocalFilePath = "C:UserspanchalsDesktopsample.txt"
DownloadStatus = URLDownloadToFile(0, strURL, LocalFilePath, 0, 0)
If DownloadStatus = 0 Then
MsgBox "File Downloaded. Check in this path: " & LocalFilePath
Else
MsgBox "Download File Process Failed"
End If
End Sub
You need to modify the code as per your own requirement.
Reference:
Download Files with VBA URLDownloadToFile
Thank you for the answer!! Like I said, I am new in VBA. The code is in excel flie and when it reach at "InputElement.Click" popup comes and ask to 1.Open, 2 Save & 3 SaveAS. Is possible to save directly in to my drive?
– Ravi Sharma
Jan 22 at 12:25
If you have URL of the file on the time of click than you can use the above code to save the file directly to your drive. it will not show a Save As pop up to you. I suggest you to directly run the sample code to get the idea about it.
– Deepak-MSFT
Jan 23 at 3:26
Thank you for reply, i did same as you suggest but did not get much success. In the link, extension not define (.xls)
– Ravi Sharma
Jan 24 at 8:47
nicetime.com/reports/…
– Ravi Sharma
Jan 24 at 8:50
add a comment |
You did not posted the code which actually downloads the file. In title of the thread, You said VBA Excel but your code using IE object.
If you have the URL of the file than you can refer example below for downloading the file.
Private Declare PtrSafe Function URLDownloadToFile Lib "urlmon" _
Alias "URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, _
ByVal szFileName As String, ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long
Sub demo()
Dim strURL As String
Dim LocalFilePath As String
Dim DownloadStatus As Long
strURL = "http://data.iana.org/TLD/tlds-alpha-by-domain.txt"
LocalFilePath = "C:UserspanchalsDesktopsample.txt"
DownloadStatus = URLDownloadToFile(0, strURL, LocalFilePath, 0, 0)
If DownloadStatus = 0 Then
MsgBox "File Downloaded. Check in this path: " & LocalFilePath
Else
MsgBox "Download File Process Failed"
End If
End Sub
You need to modify the code as per your own requirement.
Reference:
Download Files with VBA URLDownloadToFile
You did not posted the code which actually downloads the file. In title of the thread, You said VBA Excel but your code using IE object.
If you have the URL of the file than you can refer example below for downloading the file.
Private Declare PtrSafe Function URLDownloadToFile Lib "urlmon" _
Alias "URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, _
ByVal szFileName As String, ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long
Sub demo()
Dim strURL As String
Dim LocalFilePath As String
Dim DownloadStatus As Long
strURL = "http://data.iana.org/TLD/tlds-alpha-by-domain.txt"
LocalFilePath = "C:UserspanchalsDesktopsample.txt"
DownloadStatus = URLDownloadToFile(0, strURL, LocalFilePath, 0, 0)
If DownloadStatus = 0 Then
MsgBox "File Downloaded. Check in this path: " & LocalFilePath
Else
MsgBox "Download File Process Failed"
End If
End Sub
You need to modify the code as per your own requirement.
Reference:
Download Files with VBA URLDownloadToFile
answered Jan 21 at 1:56
Deepak-MSFTDeepak-MSFT
735116
735116
Thank you for the answer!! Like I said, I am new in VBA. The code is in excel flie and when it reach at "InputElement.Click" popup comes and ask to 1.Open, 2 Save & 3 SaveAS. Is possible to save directly in to my drive?
– Ravi Sharma
Jan 22 at 12:25
If you have URL of the file on the time of click than you can use the above code to save the file directly to your drive. it will not show a Save As pop up to you. I suggest you to directly run the sample code to get the idea about it.
– Deepak-MSFT
Jan 23 at 3:26
Thank you for reply, i did same as you suggest but did not get much success. In the link, extension not define (.xls)
– Ravi Sharma
Jan 24 at 8:47
nicetime.com/reports/…
– Ravi Sharma
Jan 24 at 8:50
add a comment |
Thank you for the answer!! Like I said, I am new in VBA. The code is in excel flie and when it reach at "InputElement.Click" popup comes and ask to 1.Open, 2 Save & 3 SaveAS. Is possible to save directly in to my drive?
– Ravi Sharma
Jan 22 at 12:25
If you have URL of the file on the time of click than you can use the above code to save the file directly to your drive. it will not show a Save As pop up to you. I suggest you to directly run the sample code to get the idea about it.
– Deepak-MSFT
Jan 23 at 3:26
Thank you for reply, i did same as you suggest but did not get much success. In the link, extension not define (.xls)
– Ravi Sharma
Jan 24 at 8:47
nicetime.com/reports/…
– Ravi Sharma
Jan 24 at 8:50
Thank you for the answer!! Like I said, I am new in VBA. The code is in excel flie and when it reach at "InputElement.Click" popup comes and ask to 1.Open, 2 Save & 3 SaveAS. Is possible to save directly in to my drive?
– Ravi Sharma
Jan 22 at 12:25
Thank you for the answer!! Like I said, I am new in VBA. The code is in excel flie and when it reach at "InputElement.Click" popup comes and ask to 1.Open, 2 Save & 3 SaveAS. Is possible to save directly in to my drive?
– Ravi Sharma
Jan 22 at 12:25
If you have URL of the file on the time of click than you can use the above code to save the file directly to your drive. it will not show a Save As pop up to you. I suggest you to directly run the sample code to get the idea about it.
– Deepak-MSFT
Jan 23 at 3:26
If you have URL of the file on the time of click than you can use the above code to save the file directly to your drive. it will not show a Save As pop up to you. I suggest you to directly run the sample code to get the idea about it.
– Deepak-MSFT
Jan 23 at 3:26
Thank you for reply, i did same as you suggest but did not get much success. In the link, extension not define (.xls)
– Ravi Sharma
Jan 24 at 8:47
Thank you for reply, i did same as you suggest but did not get much success. In the link, extension not define (.xls)
– Ravi Sharma
Jan 24 at 8:47
nicetime.com/reports/…
– Ravi Sharma
Jan 24 at 8:50
nicetime.com/reports/…
– Ravi Sharma
Jan 24 at 8:50
add a comment |
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%2f54273295%2fdownload-excel-direct-to-drive-c-no-save-as-option-require-vba-excel%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