vba

VBA download form URL with login that redirect to another one

淺唱寂寞╮ 提交于 2021-02-08 07:18:47
问题 the website requires login then redirect you to other url then download the file this function works fine with url with no redirction but not with my case Function DownloadFile(URL As String, Path As String, UserName As String, Password As String) As Boolean DownloadFile = False Dim WinHttpReq As Object Set WinHttpReq = CreateObject("MSXML2.ServerXMLHTTP.6.0") WinHttpReq.Open "GET", URL, False, UserName, Password WinHttpReq.send Set oStream = CreateObject("ADODB.Stream") oStream.Open oStream

Save as different file type

核能气质少年 提交于 2021-02-08 07:14:10
问题 I would like to make my macro able to save a xlsx file as csv exactly with the same name when running it. This is what I tried: ActiveWorkbook.saveas Filename:=ActiveWorkbook.Path & "\" & _ ActiveWorkbook.Name & ".csv", FileFormat:=xlCSV, CreateBackup:=False However, it saves the file as .xlsx.csv (i.e, a file called prices.xlsx is saves as prices.xlsx.csv) How could I save the file with a different file extension, without the .xlsx? 回答1: If you want to make it more failsafe, in case your

Get byte Array from current opened downloaded Word Document .docm from Sharepoint, without save to local drive

时光毁灭记忆、已成空白 提交于 2021-02-08 06:47:49
问题 How can I get the byte array of the opened Word Document (.docm) without saving it to a local drive first. The document will be opened on a Thin Client without any local drive from SharePoint. When the user want to save the changes, I need to send the byte array to a web-service to process it. (Not back to SharePoint). Dim filePath As String Dim fileName As String Dim fullFileName As String filePath = ThisDocument.path fileName = ThisDocument.Name fullFileName = filePath + "/" + fileName the

Administrator Limited Number of Outlook Items

女生的网名这么多〃 提交于 2021-02-08 06:40:32
问题 How to change the loop? I really need help. I have a macro to download PDFs from messages with the following code: Sub SaveAttachmentsFromSelectedItemsPDF2() Dim currentItem As Object Dim currentAttachment As Attachment Dim saveToFolder As String Dim savedFileCountPDF As Long saveToFolder = "c:\dev\pdf" 'change the path accordingly savedFileCountPDF = 0 For Each currentItem In Application.ActiveExplorer.Selection For Each currentAttachment In currentItem.Attachments If UCase(Right

VBA, Application-defined or Object Error, changing Pivot Filter

天大地大妈咪最大 提交于 2021-02-08 06:39:43
问题 I am trying to change the pivot filter using vba based on a cell. I get error Application-defined or Object Error on my second line of code. Sub RefreshPivots() Sheets("Details").PivotTables("PivotTable1").PivotCache.Refresh Sheets("Details").PivotTables("PivotTable2").PivotCache.Refresh temp = Sheets("Input").Range("H2") Sheets("Details").PivotTables("PivotTable1").PivotFields("Period").PivotFilters.Add Type:=xlCaptionEquals, Value1:=temp End Sub I am trying to switch to a date that I have

Excel VBA Autofilter using array - multiple values in same column

孤者浪人 提交于 2021-02-08 06:34:23
问题 I feel like the answer is out there, but after lots of searching and experimenting, I am still coming up short. So can see in the first image that column O had a comma separated list of values. I would like my routine to filter the data on column A using the entire list when the user double click on the cell containing the list. My code reads: Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean) If Not Intersect(Target, Range("O:O")) Is Nothing Then Sheet1.Cells

How to insert a HTML into Excel

眉间皱痕 提交于 2021-02-08 06:12:41
问题 I have a map on a website which changes with time (interactive) and I would like to insert it on the excel sheet. I am using this code but it does not show the HTML: Private Sub Mapit() URL = Sheets("sheet1").Cells(1, 1) //Here there is written the link to the website that want to show on excel Sheets("sheet1").Pictures.Insert(URL).Select End Sub Is that possible? I guess that Sheets("sheet1"). Pictures .Insert(URL).Select is the problem but I am not able to find which is the correct way.

How to insert a HTML into Excel

﹥>﹥吖頭↗ 提交于 2021-02-08 06:09:16
问题 I have a map on a website which changes with time (interactive) and I would like to insert it on the excel sheet. I am using this code but it does not show the HTML: Private Sub Mapit() URL = Sheets("sheet1").Cells(1, 1) //Here there is written the link to the website that want to show on excel Sheets("sheet1").Pictures.Insert(URL).Select End Sub Is that possible? I guess that Sheets("sheet1"). Pictures .Insert(URL).Select is the problem but I am not able to find which is the correct way.

Using a class module variable in a userform (Error '424' object required)

血红的双手。 提交于 2021-02-08 05:58:40
问题 I have a class module which hosts a worksheet_change sub, and in that sub a Userform has to pop up. I want to use a number of variables from the class module in the Userform's code. Whatever I do, however, I can't get it to work. I have tried to apply the method from this very lenghty guide, but to no avail. Other threads on SO weren't able to help me. Private cell As Range Public WithEvents m_wb As Workbook Property Get cellr() As Range Set cellr = cell End Property Property Set cellr

I need to import data from Excel to SQL Server using VBA

你说的曾经没有我的故事 提交于 2021-02-08 05:48:18
问题 I am trying to import data from another Excel workbook on my PC into SQL Server. I tried with this code, but it doesn't work: Sub insertion() Dim conn As ADODB.Connection Dim rs As ADODB.Recordset Dim sConnString As String Dim rsstring As String Dim m, nrows As Integer Dim loRH As Excel.ListObject Workbooks("test-vba.xls").Activate *connection* Set conn = New ADODB.Connection Set rs = New ADODB.Recordset conn.Open sConnString MsgBox "Start" Set loRH = wkb.ListObjects(1) loRH.ListColumns(1)