C++/VB - Copying to a relative cell range
Asked By Script Hack...why read manuals
10-Mar-10 06:09 PM
To all VBscript Gurus,
I am attempting to copy a string variable to a relative cell range. I have
been playing around with the Range command, but this only works for absolute
ranges. Here is layman's logic that I want to convert to VBScript:
dim string = "this variable"
dim B = 10
copy string to cells (A1:A(1+B))
so in other words "this variable" will be copied to the A1:A11 range. Seems
simple enough, but I just wasted 90 minutes and didnt' get anywhere.
Excel
(1)
ActiveCell.Worksheet
(1)
VBA
(1)
HaveuteSeemsThis
(1)
ScriptCenter
(1)
FillDown
(1)
VBscript
(1)
Fillit
(1)
LikeToCode replied to Script Hack...why read manuals
This is VBS you cannot "Dim" a variable and assign it a value. You must "Dim"
a variable then separately assign its value.
Dim string, B
string = "This Variable"
B = 10
This can help you get your script started.
http://gallery.technet.microsoft.com/ScriptCenter/en-us/56db8d08-6793-4083-8075-9a01ee4fa6a7
Tom Lavedas replied to Script Hack...why read manuals
have
ute
Seems
This is VBA in Excel, right? Here is one way I can think of ...
Sub fillit()
Dim sString As String, B As Single
sString =3D "this variable"
B =3D 10
With ActiveCell.Worksheet
.Range("A1") =3D sString
.Range("A1:A" & B).FillDown
End With
End Sub
_____________________
Tom Lavedas

C++ / VB system32 \ tskill.exe And EXCEL by VBS file. . . Hi. I got a job about writing some txt files into a Excel sheet. Some text1: value1 Some text2: value2 . . . and so on. . . So today I wrote a A problem I found was that if one said something wrong to the msgBoxes from Excel, or whatever, then it could freeze the sheet. . . To avoid that, I simply used the Say No to the first question, and the freeze problem is gone :) My knowlede about Excel syntax is almost one line, something like this: oExcelSheet.cells(1, 1).value so any if not fso.folderExists(sTargetPath) _ then fso.createFolder(sTargetPath) ' sExcelEXE = "%ProgramFiles% \ Microsoft Office \ Office10 \ Excel.exe" sExcelEXE = fso.getAbsolutePathName(wso._ expandEnvironmentStrings(sExcelEXE)) if not fso.fileExists(sExcelEXE) then sExcelEXE = "excel.exe" ' sVer = fso.getFileVersion(sExcelEXE) if sVer = "" then sVer = "?" ' wScript.echo """excel.exe"", ver " & sVer sVer = fso.getFileVersion(wScript.fullName) wScript.echo wScript.name & ", ver " & sVer & vbCrLf vbDefaultButton2 +vbOkCancel _ -(256+2)*bSheetExist +vbCritical, "Warning!") case vbCancel wScript.quit case vbNo KillApp "excel": wso.run"""" & sExcelEXE _ & """ """ & sTargetFile & """": wScript.quit case else KillApp "excel" end select if wScript
DLL (Created in VB6) problem Hi folks, I tried to create a dll library for Excel VBA but I got an error message which is out of my knowlege. Please help. In clName End Sub clName: Public Function SN(strSheet As Integer) As String Dim XLApp As Excel.Application SN = XLApp.ActiveWorkbook.Sheets(strSheet).Name End Function Then, I compiled it to dll and registed it. After all, I added the library to Excel vba and had the following code to call it. Public Sub test2() Dim xlFunction As test appreciated. Thanks in advance. Tim ? Hi folks, ? ? I tried to create a dll library for Excel VBA but I got an error message ? which is out of my knowlege. Please help. What error message? Paul ~~~~ Microsoft MVP (Visual Basic) Hi Paul, When I called the function from Excel VBE, I got the following error message: Run Time error '91' object variable or with
DOC itself. r u getting me? thank you For any inserted Office document, examples include Excel Spreadsheet, Power Point Presentation, Visio, etc., extraction is easy. These documents can all be extracted load and save these documents. Use CoCreateInstance to instantiate the OLE Auomation Application(i.e., Excel, Power Point, Visio, etc). I gave the recipe in one of my previous posting in your thread. The only problem with excel files is that once extracted they are invisible. You must make them visible to see group / microsoft.public.dotnet.framework.interop / browse_thread / thread / 2ce134250d3d061b / 64d73629838242f4?hl = en&lnk = st&q = excel+michael+phillips#64d73629838242f4 I have not tried inserted images. However using the DFViewer, I see me say by computing binaries only? Also i viewed the code you provided to extract excel, i suppose it do not require creating an instance of EXCEL. Is this true? By reading the compobj i figured out if the excel Workbook stream is BIFF8, is this the right way to probe BIFF format? Also i previous post on this thread will eventually achieve this goal. You can either use the Excel COM Automation API or the method that I provided. You still need an instance of
Application.OnTime Not Working I have created the following VBS code: MyTest Set objExcel = CreateObject("Excel.Application") MsgBox "Before OnTime" objExcel.Application.OnTime Now + TimeValue("00:00:05"), "MyTest" MsgBox "After errors. Any help would be appreciated. I cannot run it because I do not have Excel, but what exactly are you trying to do? Do you want "mytest()" to run once illustrates them. The first is due to the fact that you exit your program before Excel has a chance to do anything. When you exit the VBScript program, the Excel directive goes away, too. So sorry. You have to specifically insist that Excel not go away just yet by ensuring that your program not away as the below shows. Now you can finally see Excel make the call. And Excel is deeply unhappy (but at least you get an error message letting you know that Excel is trying to make the call). Why does it die? Excel is trying to make
there a simple way to create a script that will open up the file in Excel with the first 5 values in worksheet 1, the next 3 in worksheet 2, and to do. After you are finished, turn off the macro recorder, then go into the vba editor and look at your code. It will be that difficult to convert to vbs use the ADO objects to create the .XLS with the multiple sheets, without involving the Excel object? I think I have a script to create .MDB files directly with ADO hidden objTextFile, CSVdata Dim d, sheet, row, col Set objFSO = CreateObject("Scripting.FileSystemObject") Set objExcel = CreateObject("Excel.Application") objExcel.Visible = True objExcel.Workbooks.Add Set objWb = objExcel.ActiveWorkbook Set objTextFile = objFSO.OpenTextFile UBound( aParms ) Step 2 sSQL = 3D Join( Array( _ , "INTO [" & aParms( nIdx ) & "]" _ , "IN '" & sXFSpec & "' 'Excel 8.0;'" _ , "FROM " & sTblName ), " " ) WScript.Echo sSQL oADOCN.Execute sSQL Next oADOCN.Close works Region], [Land], [Telefax] = INTO [FrsPart] IN 'C: \ wis \ _vbs \ 0506 \ dev \ forum \ impadoexcel \ impadoexcel.xls = ' 'Excel 8.0;' FROM impadoexcel.csv SELECT [Firma], [Position], [Ort], [PLZ], [Telefon] INTO [SecPart] IN 'C: \ wis \ _vbs \ 0506 \ dev \ forum \ impadoexcel \ impadoexcel.xls' 'Excel 8.0;' FROM impadoexcel.csv and of course two sheets in impadoexcel.xls, but YMMV is easy to mess up and there may be problems with other versions of ADO, Excel, ADO Text Driver. Thanks for the interesting / inspiring idea! Paul Randall schrieb: [. . .] I really like