excel-vba

UserForm error: Method 'Properties' of object '_VBComponent' failed

本秂侑毒 提交于 2020-01-02 04:31:13
问题 I want to edit my UserForm object in VBE with code. When I use the following, I get an error as in post title: Sub myTest() ThisWorkbook.VBProject.VBComponents("UserForm1").Properties("Caption") = "myCaption" End Sub I tried changing "Caption" to "caption", the same error. Also this error happens when I try to set Width or Height properties, not always at first time, but when I run the code again to resize. Edit 1: "Trust access to the VBA project object model" in macro settings is enabled.

Reading and working with strings longer than 255 with ADODB Excel 2010 VBA

对着背影说爱祢 提交于 2020-01-02 03:43:07
问题 Here' a thing for you guys: I want to read information from from a closed workbook using ADODB in VBA EXCEL. It happens that the strings in the cells in excel sometimes are with a length bigger than 255. And then here is this limitation: http://support.microsoft.com/kb/189897 "Your data may be truncated to 255 characters if the first 8 records for the field(s) being truncated contain 255 or fewer characters. The Microsoft Excel ODBC driver will, by default, scan the first 8 rows of your data

VBA Convert date to week number

两盒软妹~` 提交于 2020-01-02 03:17:38
问题 In VBA I want to convert a date as 03/11/2017(DD/MM/YYYY) into the week number for that date. Until now I have the following code: 'geting the date out of the string HeadlineTemp = Mid(VRHeadline, InStr(VRHeadline, "[") + 1, 10) 'switch "." to "/" HeadlineTemp = Replace(HeadlineTemp, ".", "/") 'convert to a date FristVRFirstKW = CDate(HeadlineTemp) Now, I need a function to convert that date into the week number of the year. First week day is Monday. 回答1: To make the Week Number with Monday

VBA - How to add a collection to a collection of collections

会有一股神秘感。 提交于 2020-01-02 01:17:12
问题 I am trying to create code to represent a form document using VBA in Word 2007. I have created classes to represent Section, QuestionSet and Question. So I have 15 Sections. I have created a function to create each 'Section' Object add it to the 'Sections' Collection then destroy the object, the result being that the objects remain persistent in the collection (or something). Is it possible to use the same method to add collections to collections or would I have to define each collection

Automatically Update Data in Other Excel Sheets of a Workbook

蹲街弑〆低调 提交于 2020-01-02 00:32:10
问题 I have VBA code that takes my data on the "master" worksheet and puts it in the other sheets in a workbook. The problem I am having is that the new data doesn't update automatically. I would like to develop code that will automatically update my worksheets. This is the code that I have now. Sub test() Dim LR As Long, i As Long LR = Range("A" & Rows.Count).End(xlUp).Row For i = 2 To LR If Range("B" & i).Value = "AP" Then Rows(i).Copy Destination:=Sheets("AP").Range("A" & Rows.Count).End(xlUp)

Inserting multiple values into a SQL database from EXCEL through VBA script

杀马特。学长 韩版系。学妹 提交于 2020-01-01 19:59:26
问题 Just trying to insert data from 5 cells via a VBA script, into a column on an SQL server 08 database. So basically I have 1 table with 4 columns, I want to insert multiple sets of data into the columns at once which would insert data into the DB with the below result.. Server Name Middleware Version License TEST6 Testing 1 1 TEST6 Testing1 1 1 TEST6 Testing2 1 1 TEST6 Testing3 1 1 I know the values are not correct on the below code, but I get the error message (below the vba code) when the

How to save worksheets as CSV files in UTF-8 format with Excel for Mac 2011?

℡╲_俬逩灬. 提交于 2020-01-01 19:48:14
问题 I have the following Excel VBA script which I use in Excel for Mac 2011 to export all the worksheets of an Excel file to .csv files. Sub save_all_csv() On Error Resume Next Dim ExcelFileName As String ExcelFileName = ThisWorkbook.Name For Each objWorksheet In ThisWorkbook.Worksheets ExcelFileNameWithoutExtension = RemoveExtension(ExcelFileName) CsvFileName = ExcelFileNameWithoutExtension & "__" & objWorksheet.Name & ".csv" Application.DisplayAlerts = False objWorksheet.SaveAs Filename:="data

How to save worksheets as CSV files in UTF-8 format with Excel for Mac 2011?

纵然是瞬间 提交于 2020-01-01 19:48:06
问题 I have the following Excel VBA script which I use in Excel for Mac 2011 to export all the worksheets of an Excel file to .csv files. Sub save_all_csv() On Error Resume Next Dim ExcelFileName As String ExcelFileName = ThisWorkbook.Name For Each objWorksheet In ThisWorkbook.Worksheets ExcelFileNameWithoutExtension = RemoveExtension(ExcelFileName) CsvFileName = ExcelFileNameWithoutExtension & "__" & objWorksheet.Name & ".csv" Application.DisplayAlerts = False objWorksheet.SaveAs Filename:="data

VBA Excel 2010 - Paste directly from clipboard

杀马特。学长 韩版系。学妹 提交于 2020-01-01 19:34:41
问题 I am trying to paste directly from the clipboard into an excel document and have it so it is transposed Dim DataObj As MSForms.DataObject Set DataObj = New MSForms.DataObject DataObj.GetFromClipboard strPaste = DataObj.GetText(1) strPaste.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _ False, Transpose:=True The strPaste does have the correct data but it bugs out on the .PasteSpecial saying object required 回答1: I think you need to specify target where to paste and on it call

Pulling data from SAP using Excel Macros

一个人想着一个人 提交于 2020-01-01 19:08:27
问题 So I am trying to pull data from SAP using excel macros. I am new to VBA so please bear with me. I found a topic on here called VBA pulling data from SAP for dummies and I am confused. What I am trying to do is as follows: Copy a notification number from a list in excel. Go to the appropriate screen in SAP and paste this number in the search box. Open the long text box. Copy the long text. Paste into excel. Here is the link VBA pulling data from SAP for dummies I can't seem to get by Set