vba

How to transfer an excel spreadsheet to an access database

﹥>﹥吖頭↗ 提交于 2021-01-29 16:14:28
问题 I'm making a program to track my weight, calories I eat in a day, and the date, to help me lose weight. I'm manually putting in these values into a spreadsheet with those three columns (date, calories, weight). I want to transfer the information in these three columns into an access database. Code so far: Sub transferdata() Dim cn As New ADODB.Connection Dim rs As New ADODB.Recordset connStr = "C:\Users\sachu\Desktop\Assignment 5\CalorieDatabase.mdb" providerStr = "Microsoft.ACE.OLEDB.12.0"

Turn off enable calculation

不羁的心 提交于 2021-01-29 16:13:29
问题 I have a workbook with a lot of different formulas and I have one worksheet in it called Map, that I need to not auto calculate, every time I enter new data into a different worksheet. I have the following VBA code below on this worksheet. The problem is I need to manually go to the Developer tab, Properties, EnableCalculation, and select False. When I do it this way, the code works perfectly. However when I close and re-open the workbook, the EnableCalculation in the Properties, has been

Excel VBA - Access Website, generate report & press save on IE dialog bar

放肆的年华 提交于 2021-01-29 16:13:09
问题 I have a question regarding a topic that is already discussed in some other threads and forums but I do not manage to make it work for me. So I came here to ask that questions concerning my individual code. Basically, I access an intranet-site and based on some input (via checkboxes) a report is created with data from SAP. My problem arises after the report is generated and IE prompts me to press the "save" button on its dialog box. I do not manage to automate that part. Could you help me

VBA Excel instance doesn't close when opened from MS Access - late binding still same error

馋奶兔 提交于 2021-01-29 15:37:29
问题 here's my original post VBA Excel instance doesn't close when opened from MS Access - late binding it was answered and i didn't realize that the xlsm file still isn't closed when I accepted the answer. The reason why this is such a huge problem, is because when there's an open ghost .xlsm file, the next .xlsm file that opens doesn't run the startup macro. so, all my automations are failing because the previous .xlsm is sitting in memory. So, I have many automations scheduled to run. They're

How to open a macro enabled Excel file on a SharePoint in edit mode from an Excel vba?

岁酱吖の 提交于 2021-01-29 15:23:57
问题 I have an macro enabled Excel file on a SharePoint that when a user opens it from the SharePoint the file opens programmatically another macro enabled Excel file on the same SharePoint. The file being opened by the vba macro needs to be edited, and must be editable by multiple users at the same time. However I can't get it to even open in edit mode. Using Office 365 I've tried << ActiveWorkbook.LockServerFile >> but always get an error message << Run-time error 1004: Method 'LockServer' of

Calls to lstrlenA or lstrlenW are returning unexpected values

别来无恙 提交于 2021-01-29 15:21:45
问题 Summary: In Excel VBA, I've got a function that gets CF_TEXT from the clipboard, and another function for CF_UNICODETEXT. I use lstrlenA / lstrlenW to get the length of the string, but I'm getting unexpected results from those calls. I'd like help to understand why. Details: Within my functions, I use CopyMemory after opening the clipboard to get a byte array that I can then turn into a string. I'm in the process of adapting the project for 64-bit Office, and wanted to make sure everything

Function to calcuute future values =)

若如初见. 提交于 2021-01-29 15:14:53
问题 guys, need help with my function, just one moment...if "Range" is null (Cell have value "") then ignore it, because i have alredy done it to count i dont know how to change for ignoring such cells. Thank you Public Function future (ByVal r1 As Range, ByVal r2 As Range, ByVal r3 As Byte) As Variant On Error GoTo errHandler If (r1.Columns.Count <> r2.Columns.Count Or r1.Rows.Count <> 1 Or r2.Rows.Count <> 1) Then future = "ERROR!""" Exit Function End If Dim denominatorSum As Double Dim

Compress all the pictures to email size pixel (96)PPI by using command button

柔情痞子 提交于 2021-01-29 15:13:48
问题 I want to compress all the pictures in excel workbook to email size pixel 96( ppi) by using command button with the following code. But it doesn't work to compress all pictures .It can only compress 1 picture. Sub test() Dim wsh As Worksheet Set wsh = Worksheets("Sheet1") wsh.Activate wsh.Shapes(1).Select SendKeys "%e", True SendKeys "~", True Application.CommandBars.ExecuteMso "PicturesCompress" End Sub 回答1: Try using a For Each loop to iterate through all shapes in the worksheet: Sub test()

Word Macro to change footer font size and set it different from the different headers and the body in the documents?

对着背影说爱祢 提交于 2021-01-29 15:03:06
问题 I am trying to set a different font size for the footer in the document from the rest of the body. Moreover, how can I change font size of certain headings in the document without having knowledge of what the heading size might be? Any help would be appreciated! I am posting what I tried so far. Thank you! Sub MyMacro() Selection.ParagraphFormat.LineSpacing = LinesToPoints(1.5) Set myRange =ActiveDocument.Sections.First.Headers(wdHeaderFooterPrimary).Range With myRange.Font .Name = "Palatino

VBA Excel save .xlsx file with the flexible name

你。 提交于 2021-01-29 14:41:45
问题 I would like to save my file with the flexible name, which will change as the cell value changes. The one answer is here: Save a file with a name that corresponds to a cell value however, I want also some fixed part of the name, which won't change unlike the part described in the query above. Basing on this solution I tried to write something as follows: Sub Save () Dim name As String, Custom_Name As String name = Range("A2").Value Custom_Name = "NBU" & name & "- Opportunity list.xlsx"