vba

Excel workbook gets opened repeatedly after closing

限于喜欢 提交于 2021-02-05 12:04:50
问题 I have used the method Application.ontime() for scheduling some macros.After closing the workbook, it gets opened again and again. to overcome this problem, I set another event on workbook- BeforeClosed. Now it is showing runtime error 1004:Method 'OnTime' of 'Object'_Application failed.I am not getting why this happening even after reffering the help context from web. Below code is given. Private Sub Workbook_Open() starttime = Now + TimeValue("00:02:00") Application.OnTime EarliestTime:

Read Registry on Windows 7 with VBA Permission

你。 提交于 2021-02-05 11:59:55
问题 I have a line of code that has worked flawlessly for years on 50+ PCs (Vista & Windows 7 32 & 64 bit) in Access 2007 and Access 2010. RegStr = fReturnRegKeyValue(HKEY_LOCAL_MACHINE, "Software\ThisApp\App", "Activation") On one specific PC (Windows 7 64bit) with An Access2010/VBA module (32 bit) The line of code above does not see the registry key. When I change HKEY_LOCAL_MACHINE to HKEY_CURRENT_USER,it works fine. RegStr = fReturnRegKeyValue(HKEY_CURRENT_USER, "Software\ThisApp\App",

Read Registry on Windows 7 with VBA Permission

限于喜欢 提交于 2021-02-05 11:58:06
问题 I have a line of code that has worked flawlessly for years on 50+ PCs (Vista & Windows 7 32 & 64 bit) in Access 2007 and Access 2010. RegStr = fReturnRegKeyValue(HKEY_LOCAL_MACHINE, "Software\ThisApp\App", "Activation") On one specific PC (Windows 7 64bit) with An Access2010/VBA module (32 bit) The line of code above does not see the registry key. When I change HKEY_LOCAL_MACHINE to HKEY_CURRENT_USER,it works fine. RegStr = fReturnRegKeyValue(HKEY_CURRENT_USER, "Software\ThisApp\App",

Save as pdf using Mac Excel VBA

[亡魂溺海] 提交于 2021-02-05 11:51:27
问题 My Excel VBA on Mac OS to save as PDF sometimes doesn't work. It will give "Error while printing" then "Run-time error '1004': Application-defined or object-defined error". My code, which worked yesterday: 'a) For Windows Dim wksSheet As Worksheet, PS As String PS = Application.PathSeparator If InStr(1, Application.OperatingSystem, "Windows") > 0 Then Set wksSheet = ActiveSheet wksSheet.ExportAsFixedFormat Type:=xlTypePDF, FileName:= _ ThisWorkbook.Path & PS & pdfName, Quality:

Excel VBA Change Color Of Cell Based On Value

吃可爱长大的小学妹 提交于 2021-02-05 11:46:48
问题 I need some help with a function that can change the color of the cell based on if the value of the cell is equal to the value of another, currently the cell holds an =COUNT(##:##) and I need to to Change the color from red to green if that value is equal to the value in another cell. With my limited knowledge of VBA and excel I came up with this Function ChangeColor(CellColor As Range) Application.Volatile True If CellColor = cell.Value Then ChangeColor = cell.Interior.ColorIndex = 14 End

Clicking on hyperlink with partial href on Internet Explorer using vba

喜你入骨 提交于 2021-02-05 11:42:08
问题 Hi I am trying to create a script to click on a link of which I can provide a partial link. It would be great if someone may please advise how I can do this <a href="website/report/download.json?refId=3e49762e-8edc-47c2-a282-11ee3c64e85a&reportType=xlsx&fileName=GeneralExtract.xlsx&obo>GeneralExtract.xlsx</a> Set i = CreateObject("InternetExplorer.Application") Dim idoc As MSHTML.HTMLDocument Set idoc = i.document Set eles6 = idoc.getElementsByTagName("a") For Each ele6 In eles6 If ele6.href

What are macid filetypes in excel vba

落花浮王杯 提交于 2021-02-05 11:36:44
问题 What are all the possible MacID("filetype") I need the one specifically for CSV but i couldn't find a list anywhere online surprisingly. 回答1: First run: mdls "FileName" Find the TypeCode in the Output: kMDItemFSTypeCode = "TEXT" You can use: Dir(Path,MacID("TEXT")) 回答2: Just a little aside for this thread. Yes there are few places to find details of the MacIDs, but beware. If a file is create on a PC it may not have its MacID set correctly, or at all for that matter. I am working with Excel

VBA Function Avoiding If Statements

99封情书 提交于 2021-02-05 11:33:06
问题 I'm building a pretty complicated VBA workbook, and one of the issues on running much of the code is performance. I have a built in function that does, more or less, the following Public Function zzz (xxx as String) as String if xxx = "apple" then zzz = "orange" if xxx = "appple2" then zzz = "orange2" if xxx = "apple3" then zzz = "apple3" etc. (but with about 30 strings instead). I call this function multiple times. Is there a better way to do this? 回答1: Hardly. And for 30 strings, this

Get only today's appointments through Outlook VBA

一笑奈何 提交于 2021-02-05 11:24:05
问题 I am extracting all appointments across all Outlook accounts for today. I am experiencing the same issue encountered in this post here, but I am trying to do this through VBA. Originally I managed to get the appointments for today, but it would also return reoccurring meetings that are not taking place today (like in the linked question). I do not understand how the Powershell code, in the answer, manages to filter out the reoccurring appointments, because in my VBA attempt I get the whole

Access VBA: using `do while` loop to update a recordset

一世执手 提交于 2021-02-05 11:22:15
问题 I would like to get a result using a do while loop. However, my result gives only one record... What I'm trying to do is: Move through rs (record-set) records Check if a value in rs is equal to rs2 If so, copy the username from rs to rs2 Move to the next record Do While Not rs.BOF ' No of records in rs Do While Not rs2.EOF ' No of records in rs2 If Trim(rs2![pic_no]) = Trim(rs![pic]) Then rs![UserID] = rs2![NEW_USER] rs2.MoveNext rs.Update Else rs2.MoveNext rs.Update End If Loop rs