Excel 2010 – VBA Userforms – Vlookup via Textbox, display result in another textbox
Hi,
Thank you in advance for your time.
I have a multi-page userform and I am having problems getting the result I am after.
I am trying to get the user to enter a four digit (numeric code) into a textbox and display the contents of that code in another textbox when the user clicks in another textbox.
I have 2 textboxes.
One textbox txt_SAC_No is for the user to enter a four digit numeric code, which should return the address in another textbox txt_Site_Address.
The lookup is located in a dynamic named range
as SiteAddress which encompasses 20 columns. The first column has the code and the second column holds the actual address which is what I am after.
Included in the named range, I have set up a code of 0000 (zeros) and instead of having the address in it, I have a message in there to tell the user to manually type the address (overwriting my text message). The code, 0000, means that there is no pre-defined
address and it's a once off entry.
I do not want the address to be updated in the source of the Vlookup as it is a ‘once only’ entry and unlikely to ever be used again.
I have searched on the web and attempted to adapt various codes, but I have been unable to get anything to work.
I have some sample code I have tried, but my attempt to adapt it to my needs has not been successful.
Worksheet where data is transferred is code named: ws_Incident_Details
(which is actually sheet named “Incident Details” – but I’d like to use the ‘coded’ sheet name in case someone changes the name in the tab of the sheet
Private Sub SAC_No_AfterUpdate()
'lookup value based on SacNo
With Me
.txt_Site_Address = Application.WorksheetFunction.VLookup(CLng(Me.txt_SAC_No), wsAlarmResponseList.Range("SiteAddress"), 2, 0)
End With
End Sub
I'd really appreciate any help :) I have tried other avenues for help, but it doesn't seem like anyone wants the challenge :(
Thanking you in advance .... it will indeed be appreciated :)
Kind regards,
ShyButterfly
Hope you have a terrific day, theShyButterfly
Hi Andreas :)
The above code works like a dream :) Thank you ...
I succeeded on this ocassion on being smart, and was successful in adapting your code to auto-complete textboxes based on the SAC # details.
They ALL work purrrrfectly .... thank you SO much .....
Here's the code that worked (this is based on the Name Range only capturing the 'Column Heading' ... so I created a Named Range for each of the Column Headings (highlighted in bold ... I hope :) )
Private Sub txt_SAC_No_Change()
Dim R As Range
Set R = Range("SAC").EntireColumn.Find(txt_SAC_No.Value, _
LookIn:=xlValues, LookAt:=xlWhole)
If R Is Nothing Then
txt_Site_Address = "(not found)"
ElseIf R.Value = "0000" Then
txt_Site_Address = "(manually type the address)"
Else
txt_Site_Address = Range("SiteAddress").Cells(R.Row).Value
End If
'Manned / UnManned Site:
Set R = Range("SAC").EntireColumn.Find(txt_SAC_No.Value, _
LookIn:=xlValues, LookAt:=xlWhole)
If R Is Nothing Then
txt_Manned_UnManned_Auto = "N/A"
ElseIf R.Value = "0000" Then
txt_Manned_UnManned_Auto = "N/A"
Else
txt_Manned_UnManned_Auto = Range("MannedUnManned").Cells(R.Row).Value
End If
'txt_Business_Owner:
Set R = Range("SAC").EntireColumn.Find(txt_SAC_No.Value, _
LookIn:=xlValues, LookAt:=xlWhole)
If R Is Nothing Then
txt_Business_Owner = "N/A"
ElseIf R.Value = "0000" Then
txt_Business_Owner = "N/A"
Else
txt_Business_Owner = Range("Business").Cells(R.Row).Value
End If
'Site Type:
Set R = Range("SAC").EntireColumn.Find(txt_SAC_No.Value, _
LookIn:=xlValues, LookAt:=xlWhole)
If R Is Nothing Then
txt_Site_Type = "N/A"
ElseIf R.Value = "0000" Then
txt_Site_Type = "N/A"
Else
txt_Site_Type = Range("SiteType").Cells(R.Row).Value
End If
End Sub
With immense gratitude :)
The ShyButterfly
Hope you have a terrific day, theShyButterfly
Similar Messages
-
Excel 2010 not enough system resources to display completely
I have searched the web high and low for an answer to this issue we are having with one user who uses Excel 2010 quite extensively and I have not been able to find an answer that resolves the issue.
She keeps getting the error message "Not enough system resources to display completely." The spreadsheet in question is a simple two worksheet file that she does simple calculations on. Her PC is an HP Elitebook 8560w (only 1 month
old) with an i7 Intel processor, 8GB RAM, 500GB HDD with over 300GB free, Windows 7 Professional (64-bit) with all the latest patches and updates & Office 2010 Professional (32-bit). The video and printer drivers are all update to the latest versions.
The spreadsheet is one she has used before on her older Windows XP Pro SP3 desktop with no problems. We have tried the "set the Zoom to 100% or less" resolution that has been mentioned all over the web and it does not work.
We are still having this issue. Does anyone know how to resolve this in Excel 2010. I have seen the "solutions" for Excel XP, 7, 2000, 2003 and 2007 and they don't seem to work, or at least the ones I have tried! :-)
Would welcome all serious suggestions. Mahalo Nui Loa!I've had this problem on several computers on our network. I found various recommendations, but no solid answers. I have resolved this problem on two computers with
just the first steps performed. The third computer require also following the step highlighted in yellow below:
Deleted all temp files by:
Start > Run > enter %temp% in the search box and press Enter
Delete everything from this folder
Cleared Recent Docs List & Lower Number Displaying:
File > Options > Advanced > Scroll to Display category > change number of recent documents. To clear the list, set this to 0 and save. You can adjust up after that if you choose.
Delete files from the following folders:
(may have to view hidden files – top corner drop down > folder options > view tab > Hidden files and folders > select Show hidden files, folders and drives.
Local Service:
%windir%\ServicesProfiles\LocalService\AppData\LocalLow\Microsoft\CryptnetUrlCache\Content
%windir%\ServicesProfiles\LocalService\AppData\LocalLow\Microsoft\CryptnetUrlCache\MetaData
Network Service:
%windir%\ServicesProfiles\NetworkService\AppData\LocalLow\Microsoft\CryptnetUrlCache\Content
%windir%\ServicesProfiles\NetworkService\AppData\LocalLow\Microsoft\CryptnetUrlCache\MetaData
LocalSystem:
%windir%\System32\config\systemprofile\AppData\LocalLow\Microsoft\CryptnetUrlCache\Content
%windir%\System32\config\systemprofile\AppData\LocalLow\Microsoft\CryptnetUrlCache\MetaData
The above process worked to prevent this problem on two machines, but not another. On the one that this didn’t work, I also
Start > Programs > Windows Update > View Update History. Look for KB# 2597166
If it exists, click it and uninstall.
Can also try, though I didn’t. I may do this first, but I didn’t feel this was my issue.
Control Panel > Add/Remove Programs > Select Office > Change > Run Repair -
Display results on another page
Is it possible to display the search results on another page?
user493403,
Note exactly sure what you mean, but yes, it is. The main class used for seaching is oracle.ultrasearch.query.Request. Using this class, you set the query, language, start index, # documents to return, and other good stuff.
You get back an iterator of Documents and you build the paragraph how you want it.
Good luck,
- Stephen -
Excel 2010 - Userform - VBA How to stop 'Job No' from duplicating itself on next empty row
Hi there
Thank you in advance for taking the time to check this out.
Objective:
To prevent duplication of incident numbers in the datasheet, and format the job number with a prefix of
Inc- at the beginning. I currently have the cell customization set to “Inc”General but that only inserts the prefix in the cells on the datasheet, but is not showing in the disabled textbox in the userform.
The Problem
I have a ‘Job Number’ that is generated each time the form is opened and when the ‘Save’ button is clicked the data from the form is transferred over
The job number is generated from the previous entry +1 (auto incrementing the old fashioned way).
The problem arises when the ‘Save’ button is pressed repeatedly, the same job number and data is duplicated on the datasheet.
Is there some way to ensure that the number generated is unique, and if the ‘Save’ button is repeatedly pressed that it will just over-ride the existing information?
The number format currently used is 20150003 (incremented by 1). But what I’d like to be displayed in the form is
Inc- 20150003
The following code is in the form_initialize procedure.
Me.txtSEC_INC_No.Enabled = True
Dim irow As Long
Dim ws As ws_Incident_Details
Set ws = ws_Incident_Details
'find last data row from database'
irow = ws.Cells(Rows.Count, 1) _
.End(xlUp).Row
If ws.[a2].Value = "" Then
Me.txtSEC_INC_No.Text = 0 ' If no value in Col A, it will return a 0
Else
Me.txtSEC_INC_No.Text = ws.Cells(irow, 1).Value + 1
End If
I’d be really grateful if someone could help me out, or perhaps direct me to where I might find some coding that will achieve the result I am seeking.
I have just uploaded the latest version
My Sample form is linked to my Dropbox so you can see how it currently works (or doesn't work)
With much gratitude,
TheShyButterfly
Hope you have a terrific day, theShyButterflyI am striving to improve my VBA but ... I am far from anywhere near in understanding the code that you have in your file. I feel really bad in saying that, but I am not a pretender, and will acknowledge when I am over my head.
I was thinking "simplified" :) ...
Don't worry, also Rom wasn't build in a day. :-)
I already answered the question about the duplication of the Job number in this thread:
https://social.msdn.microsoft.com/Forums/de-DE/52f3c62f-b26e-4573-b7c2-8e7203786d7f/excel-2010-vba-userforms-vlookup-via-textbox-display-result-in-another-textbox?forum=exceldev
So let us talk a little about the TAG property, thinking "simplified" and how to save the data:
Most people start with code like this when they start there first Userform:
Cells(MyRowNumber, 1) = txtBoxA
Cells(MyRowNumber, 2) = txtBoxB
etc. many many lines till
Cells(MyRowNumber, 56) = txtBoxWhatEver
And then, after Version 1.0, they realize that they also want to load data from a row into the form. And they copy all the lines and exchange
the parts before and after the
"=" like this:
txtBoxA = Cells(MyRowNumber, 1)
txtBoxB = Cells(MyRowNumber, 2)
etc. many many lines till
txtBoxWhatEver = Cells(MyRowNumber, 56)
And maybe you have another 56 lines to "clear" the Userform, and maybe more lines... over 150 lines just for this... that is really tremendous.
I will not be
too harsh,
if it works, then
it's okay.
But often many people struggle when they look into the code because, which column in the sheet is written by this line?
Cells(MyRowNumber, 56) = txtBoxWhatEver
I've often seen that people change the code to this:
Range("A" & MyRowNumber) = txtBoxA
Range("B" & MyRowNumber) = txtBoxB
etc. till
Range("BD" & MyRowNumber) = txtBoxWhatEver
which is more clearly, but you must revise
150 lines!
And that is the point for the TAG property, which is in fact just a string. So when we write the column name ("A", "B", etc.) into the TAG property of a control, you can change the code to this:
Range(txtBoxA.Tag & MyRowNumber) = txtBoxA
Range(txtBoxB.Tag & MyRowNumber) = txtBoxB
etc.
And now the 1st trick, we can use a loop and visit all controls at once:
Dim C As MSForms.Control
For Each C In Me.Controls
If C.Tag <> "" Then
Range(C.Tag & MyRowNumber) = C
End If
Next
And when we want to load data from a row into the form, it's the same, just the other direction:
Dim C As MSForms.Control
For Each C In Me.Controls
If C.Tag <> "" Then
C = Range(C.Tag & MyRowNumber)
End If
Next
And to clear the form is also the same:
Dim C As MSForms.Control
For Each C In Me.Controls
If C.Tag <> "" Then
C = ""
End If
Next
So we can remove over 150 lines and do the same with just the 18 lines above.
Isn't that a simplification?
Think about that for a while.
Ready for the next trick? ;-)
As the TAG property is readable and writeable we can use Sub UserForm_Initialize and save a lot of manual work:
Private Sub UserForm_Initialize()
Me.txtBoxA.Tag = "A"
Me.txtBoxB.Tag = "B"
'etc. till
Me.txtBoxWhatEver.Tag = "BD"
End Sub
No time to waste,
here comes the next one. ;-)
In your file, you can have named ranges, but always have headings! And so we can get the column name e.g. from a named range:
Me.txtBoxWhatEver.Tag = GetColumnName(Range("WhatEver"))
Function GetColumnName(ByVal R As Range) As String
Dim S As String
S = R.Address(1, 0)
GetColumnName = Left(S, InStr(S, "$") - 1)
End Function
Or you can use Range.Find and search for the header int the sheet and get the column name directly.
The benefit is that your form works even when the user change the layout of the sheet!
Simple
as it gets
(almost).
Andreas. -
Need help taming the DTPicker control in Excel 2010
I've created a workbook application in Excel 2010 (32 bit).
The application loads data from another workbook, which has an arbitrary number of rows of date-time stamped data in an arbitrary number of columns. On one sheet I have DTPicker controls for the start date and the end date of the range of
data it will use to generate charts and summary tables via macros.
Everything works fine on my computer, but when I deploy it to users the code breaks the first time it tries to interact with the DTPicker controls. All the data loads in fine, but when it tries to use the extremes of the data range to set the mindate
and maxdate properties of the DTPicker, it fails. The extremes are date-time values; problem seems to be accessing the control.
Tests on another machine indicate that the control can be selected, and the name in the formula bar matches what I have on my development PC. But the space inside the control looks like a garbled image instead of a date in a dropdown, and when the
user tries to access the properties of the control in design mode, the worksheet properties appear instead.
The garbled image appeared to be an issue on my PC at first as well, if the file was saved and reopened. That was addressed using a suggestion from another developer that opening and closing another file (for some unknown reason) after the workbook was opened
would eliminate the problem (which it did on the development PC).
I am looking for a solution that provides a familiar calendar pop-up and constrains date selection to the range included in the current data set (which also may get overwritten during use, with corresponding reset of the limits).
I would like the solution to be portable such that user don't need to register controls or do anything other than open the workbook and run built-in macros. I believe most of the users will have a version of Excel that matches the development PC's, but I
may also need a version checker and code branches that provide the correct functionality using the method applicable to their version. If there are certain versions that the DTPicker control will not work with, I need to know so that I can include that information
in the instructions or error handler messages.
Can this be accomplished using the DTPicker control? Or is there a "best" workaround using alternate controls that can be explicitly defined via a userform and underlying code, which activate when the user hovers over or clicks on a date control?Hi,
This is the forum to discuss questions and feedback for Microsoft Excel, the issue is related to the Excel dev, I recommend you post the question to the MSDN forum for Excel
http://social.msdn.microsoft.com/Forums/en-US/home?forum=exceldev&filter=alltypes&sort=lastpostdesc
The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us. Thank you for your understanding.
George Zhao
TechNet Community Support
It's recommended to download and install
Configuration Analyzer Tool (OffCAT), which is developed by Microsoft Support teams. Once the tool is installed, you can run it at any time to scan for hundreds of known issues in Office
programs. -
VBA inserting form fields, different positions result for different users.
I'm certianly at a loss for wrapping my head around this.
Adobe Acrobat 9 Standard (v 9.5.4)
Excel 2010 (VBA)
The problem: When I create the PDF document from Excel, I search for a string of text in order to capture the Quads for the containing rectangle. Then I use the quads to insert a control with numeric offsets. The problem that I am facing is that the offsets seem to be causing the controls to be in different locations for different users. For example, when I send (-26, -2, 100, 10) {x-offset, y-offset, width, height}; the control aligns exactly where I want it. But when another user user runs the exact same routine, or opens the PDF that I created, the fields are no longer positioned correctly.
Is there some setting that I am missing? EDIT, SOLVED: My Acrobat had a custom point to pixel setting. (Preferences > Page Display > Resolution)
Private Function makePdfControl(ByVal pdfPage As Integer, keyTerm As String, Optional ByVal keyTermLookAhead As Integer = 0, Optional ctrlType As String = "text", Optional cCoords As Variant = 0)
'pdfPage is the target page of the document
'keyTerm is the assembled search term: "Date Shipped >> DATESHIPPED"
'keyTermLookAhead is the number of words assembed into KeyTerm, zero based: "Date Shipped" >> "DATESHIPPED" >> "DATE" = 0, "SHIPPED" = 1
'ctrlType determines the type of control to place on the form; default is text
'cCoords carries an array of integers: x-offset, y-offset, width, and height
txt = ""
Dim fkt As Integer 'counter for keyTermLookAhead
Dim matchFound As Boolean 'flag that a match has been found
Dim maxWords As Integer 'the maximum number of words in pdfPage
Dim coord(3) As Integer 'local array container to provide interface for cCoords
p = 0
matchFound = False
maxWords = jso.getPageNumWords(pdfPage)
Do While p + keyTermLookAhead <= maxWords 'search all words in the target page; break if not found
p = p + 1
For fkt = 0 To keyTermLookAhead
txt = txt & jso.getPageNthWord(pdfPage, p + fkt)
Next fkt
If UCase(txt) <> UCase(keyTerm) Then 'the assembly of terms is complete, check if match
txt = "" 'prepare "txt" for next assembly
matchFound = False
Else
matchFound = True 'we've struck gold, exit the loop preserving val of "p" as the first word in the assembly
Exit Do
End If
Loop
If matchFound = True Then
Dim qtmp() As Variant
Dim q(7) As Double
qtmp = jso.getPageNthWordQuads(pdfPage, p)(0) 'collect the rectangle containing the first word of the search; output is a base-0x7 array
For a = 0 To 7
q(a) = qtmp(a) 'collect the data
Next a
If VarType(cCoords) <> 8204 Then '8204 means that we've inserted an array into the Varient type var cCoords
coord(0) = 0
coord(1) = 0
coord(2) = 100
coord(3) = 15
Else
coord(0) = cCoords(0) 'x-offset value
coord(1) = cCoords(1) 'y-offset value
coord(2) = cCoords(2) 'width value
coord(3) = cCoords(3) 'height value
End If
x0 = coord(0) 'x-offset var
y0 = coord(1) 'y-offset var
w = coord(2) 'ctrl width
h = coord(3) 'ctrl height
x = q(0) + x0
y = q(7) - h + y0
'origin point of doc matrix is lower-left corner
'origin point of control is lower left corner of the rectangle containing the first word of the search phrase
'offsets are placed from this point, negative x shifts to the left, negative y shifts down
'values are in points, not pixels
Set f = aForm.Fields.Add(keyTerm, ctrlType, pdfPage, x, y, x + w, y + h) '(uplf, lwlf, lwrt, uprt) 'add the control to the form using values passed in
End If
End Function
The above function is used while looping through the pages of the created PDF document. I am using the following function to create the document from Excel:
Private Sub exportToPDF()
DoEvents
Application.ScreenUpdating = False
Call showTabs(False)
ActiveWorkbook.ExportAsFixedFormat Type:=xlTypePDF, _
Filename:=pdfPathData, _
Quality:=xlQualityStandard, _
IncludeDocProperties:=False, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=False
Call showTabs(True)
Call locateDoc
Application.ScreenUpdating = True
End Sub
Message was edited by: ilivingston: solvedThanks for the reply, I did spend some time working on this issue... here is what I found...
1) First of all, I did have a custom Points to Inches setting in my Acrobat options... 110 vs 96. Resetting this allowed for me to see the alignment issue that my colleagues were referencing first hand.
As it turned out, my results were better, but still had inconsistency among different workstations. Leading me to..
2) The MSFT creator uses the default printer in some way to create the PDF. Because the different workstations were using different printers, we were getting different results. If everyone used an HP 1320, nobody would see any difference upon creating / adding fields.
The final solution was to change the Application.Printer to a common network printer before the export operation, and return the Application.Printer to the user default after the export completed. This has provided us with a common ground to work upon; we are lucky to have a network printer that can be used for this purpose, as I can see this becoming non-viable in environments where this would be unavailable. -
VBA command changed in Excel 2010?
We recently upgraded to Excel 2010, and a macro that always worked perfectly in 2007 is behaving strangely now.
I use the following command to insert a picture into Microsoft Excel:
Set pic = ActiveSheet.Pictures.Insert("C:\Pictures\Example.tif")
(Sorry for not inserting the above in a code block, but my web browser kept timing out while waiting for it.)
That VBA command used to work flawlessly, but ever since I upgraded to Office 2010 and email my new workbook with a picture added via a macro to anybody else
on site, the picture is gone with this error message in its place:
"The linked image cannot be displayed. The file may have been moved, renamed, or deleted. Verify that the link points to the correct file and location."
What changed in Excel 2010 to cause my VBA script to insert a LINK to a picture instead of embedding the actual picture? Does anybody with a similar
macro have this problem?Hey G North,
I had added a workaround to my code, but your one (1) line offers a better solution.
And you're right . . . my original code did include the top, left, height, and width parameters, and this was the workaround I came up with:
Dim pic As Picture, rng As Range
Set pic = ActiveSheet.Pictures.Insert("C:\Pictures\Example.tif")
Set rng = ActiveWindow.RangeSelection
With pic
.Top = ActiveCell.Top
.Left = ActiveCell.Left
.ShapeRange.LockAspectRatio = msoFalse
Resize the picture's Height and Width
to match the Current Range.
.ShapeRange.Height = rng.RowHeight
.ShapeRange.Width = rng.Width
.Placement = xlMoveAndSize
.Cut
End With
ActiveSheet.Pictures.Paste.Select
You'll notice that after I inserted my picture and resized it to fit the active range, I CUT it and then PASTED it in that same range as a PICTURE.
But again, your single line of code is preferable.
Thanks again! -
Excel 2010 Synchronize List with SharePoint List using VBA
I have used and loved the interaction between Excel and SharePoint for many generations of both solutions. It's a wonderful opportunity to integrate the familiarity and simplicity of Excel (formatting, ease of use, availability) with the data storage
and centralized list capabilities of SharePoint. Right?
When upgrading to Excel 2010, I have noticed with much dismay that much of the inherent easy to use features of previous versions were effectively stripped from this newest version. Much research, time and energy has been spent working around and resolving
the deficiency. One Microsoft based article,
http://support.microsoft.com/kb/930006, has provided the mechanics behind utilizing the "hidden" functionality... although, this capability to use VBA to create the synchronized list was available in previous versions. However, once Microsoft
published this article to this "hidden" functionality... I feel that the behavior should be supported by Microsoft in some way. OK?
Revised instructions to reproduce the problem:
1. Create a SharePoint list with 20 dummy records.
- Note the List Name ##LIST_NAME##
- Note the View GUID ##VIEW_GUID##
- Note SharePoint Base URL ##BASE_URL##
2. REVISED... In Excel 2010, save the file as Compatible "Excel 97-2003 Workbook". Close the file and reopen. Create a connected table (ListObject) in Excel using the article above to the SharePoint list. Use Sample VBA code
below:
Sub LinkedSharePointList()
ActiveSheet.ListObjects.Add SourceType:=xlSrcExternal,_
Source:=Array(##BASE_URL## & "/_vti_bin", ##LIST_NAME##, _
##VIEW_GUID##), LinkSource:=True, Destination:=Range("A1")
End Sub
3. OOPS REVISED this item. The problem is actually with ROW 21... So, update record on row 21... (no matter where the table is located... (if the "Destination" is "A1", then the problem is with ID=20, but if the Table is
shifted down to say A12, then ID=9 on row 21). Anyway... make a simple change to that record... and you'll see the ID immediately change.... as if it's a NEW record. WEIRD! Note: If the sheet is protected, then an error is displayed
indicating that a "read-only" record cannot be updated (referring to the ID cell in column A for the current row).
4. Now "synchronize" the list with excel. The former record is still in the list unchanged AND there is a NEW record in the list holding the changes. There are a number of problems that seem to ONLY occur when something changes to ROW
21.... Next, try to copy/paste multiple records across multiple rows that intersect with ROW 21. Yikes!!
I look forward to hearing others' experience!
Thanks!
MarkHere are some things that you can try (change the code, where appropriate):
Private Sub CreateList()
Dim folder As folder
Dim f As File
Dim fs As New FileSystemObject
Dim RowCtr As Integer
RowCtr = 1
Set folder = fs.GetFolder("http://excel-pc:43231/Shared Documents/Forms/") '<=Variable Location
For Each f In folder.Files
Cells(RowCtr, 1).Value = f.Name
RowCtr = RowCtr + 1
Next f
End Sub
Sub ListAllFile()
Dim objFSO As Object
Dim objFolder As Object
Dim objFile As Object
Dim pth As String
Dim WBn As Workbook
Dim ObCount As Long
Dim FileNme As String
Application.ScreenUpdating = False
Set objFSO = CreateObject("Scripting.FileSystemObject")
'Get the folder object associated with the directory
Set objFolder = objFSO.GetFolder("\\excel-pc:43231\Shared Documents\Forms\")
'** You'll need to specify your path here. By removing the http: from the path, the code liked it & found the folder. It wasn’t working previously ***
pth = "http://excel-pc:43231/Shared Documents/Forms/"
'** You'll need to specify your path here. The reason I’ve done this separately is because the path is not recognised otherwise when trying to specify it with workbook.open & using the value set for objFolder **
ObCount = objFolder.Files.Count
'** counts the number of files in the folder
'Loop through the Files collection
For Each objFile In objFolder.Files
Nm1 = Len("http://excel-pc:43231/Shared Documents/Forms/")
'** You'll need to specify your path here **
Nm2 = Len(objFile) - Nm1
FileNme = Right(objFile, Nm2)
'** I’ve done this part to find out/set the file name**
Set WBn = Workbooks.Open(pth & FileNme, , , , Password:="YourPassword")
'** opens the first file in the library – if there is no password, the remove everything from - , , , , Password:="Password1" – leaving the close bracket ‘)’
Application.ScreenUpdating = False
'** optional – you can leave the screen updating on
'<< Your coding here>>
'** The file is now open. Enter whatever code is specific to your spreadsheets.
Next
'** goes to next file within your sharepoint folder
End Sub
Sub SharePoint()
Dim xlFile As String, xlFullFile As String
Dim xlApp As Excel.Application
Dim wb As Workbook
xlFile = "\\excel-pc:43231\Shared Documents"
'http://excel-pc:43231/Shared Documents/
'****----denotes the path.(i.e) u give the path as windows search.Don't use "\" at the end.
'In the sharepoint path %20 denotes space.so u remove that and use space .
Set xlApp = New Excel.Application
xlApp.Visible = True
xlFullFile = GetFullFileName(xlFile, "Book") 'ANZ denotes starting characters of the file.
xlFile = xlFile & "\" & xlFullFile
Set wb = xlApp.Workbooks.Open(xlFile, , False)
'Once the workbook is opened u can do ur code here
wb.Close False
End Sub
Function GetFullFileName(strfilepath As String, _
strFileNamePartial As String) As String
Dim objFS As Variant
Dim objFolder As Variant
Dim objFile As Variant
Dim intLengthOfPartialName As Integer
Dim strfilenamefull As String
Set objFS = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFS.GetFolder(strfilepath)
'work out how long the partial file name is
intLengthOfPartialName = Len(strFileNamePartial)
For Each objFile In objFolder.Files 'Instead of specifying the starting characters of the file you can directly loop through all files in the folder .
'Test to see if the file matches the partial file name
If Left(objFile.Name, intLengthOfPartialName) = strFileNamePartial Then
'get the full file name
strfilenamefull = objFile.Name
Exit For
Else
End If
Next objFile
Set objFolder = Nothing
Set objFS = Nothing
'Return the full file name as the function's value
GetFullFileName = strfilenamefull
End Function
Sub SrchForFiles()
' Searches the selected folders and sub folders for files with the specified (xls) extension.
'ListTheFiles 'get the list of all the target XLS files on the SharePoint Directory
Dim i As Long, z As Long, Rw As Long, ii As Long
Dim ws As Worksheet, dd As Worksheet
Dim y As Variant
Dim fldr As String, fil As String, FPath As String
Dim LocName As String
Dim FString As String
Dim SummaryWB As Workbook
Dim SummaryWS As Worksheet
Dim Raw_WS As Worksheet
Dim LastRow As Long, FirstRow As Long, RowsOfData As Long
Dim UseData As Boolean
Dim FirstBlankRow As Long
'grab current location for later reference, for where to paste final data
Set SummaryWB = Application.ActiveWorkbook
Set SummaryWS = Application.ActiveWorkbook.ActiveSheet
y = "xls"
fldr = "\\excel-pc:43231\Shared%20Documents\Forms\AllItems.aspx"
FirstBlankRow = 2
'asd is a 1-D array of files returned
asd = ListFiles(fldr, True)
Set ws = Excel.ThisWorkbook.Worksheets(1) 'list of files
ws.Activate
ws.Range("A1:Z100").Select
Selection.Clear
On Error GoTo 0
For ii = LBound(asd) To UBound(asd)
Debug.Print Dir(asd(ii))
fil = asd(ii)
'open the file and grab the data
Application.Workbooks.Open (fil), False, True
'Get file path from file name
FPath = Left(fil, Len(fil) - Len(Split(fil, "\")(UBound(Split(fil, "\")))) - 1)
'Get file information
If Left$(fil, 1) = Left$(fldr, 1) Then
If CBool(Len(Dir(fil))) Then
z = z + 1
ws.Cells(z + 1, 1).Resize(, 6) = _
Array(Dir(fil), LocName, RowsOfData, Round((FileLen(fil) / 1000), 0), FileDateTime(fil), FPath)
DoEvents
With ws
.Hyperlinks.Add .Range("A" & CStr(z + 1)), fil
'.FoundFiles(i)
End With
End If
End If
'Workbooks.Close 'Fil
Application.CutCopyMode = False 'Clear Clipboard
Workbooks(Dir(fil)).Close SaveChanges:=False
Next ii
With ws
Rw = .Cells.Rows.Count
With .[A1:F1]
.Value = [{"Full Name","Location","Rows of Data","Kilobytes","Last Modified", "Path"}]
.Font.Underline = xlUnderlineStyleSingle
.EntireColumn.AutoFit
.HorizontalAlignment = xlCenter
End With
.[G1:IV1 ].EntireColumn.Hidden = True
On Error Resume Next
'Range(Cells(Rw, "A").End(3)(2), Cells(Rw, "A")).EntireRow.Hidden = True
Range(.[A2 ], Cells(Rw, "C")).Sort [A2 ], xlAscending, Header:=xlNo
End With
End Sub
Function ListFiles(ByVal Path As String, Optional ByVal NestedDirs As Boolean) _
As String()
Dim fso As New Scripting.FileSystemObject
Dim fld As Scripting.folder
Dim fileList As String
' get the starting folder
Set fld = fso.GetFolder(Path)
' let the private subroutine do all the work
fileList = ListFilesPriv(fld, NestedDirs)
' (the first element will be a null string unless the first ";" is removed)
fileList = Right(fileList, Len(fileList) - 1)
' convert to a string array
ListFiles = Split(fileList, ";")
End Function
' private procedure that returns a file list
' as a comma-delimited list of files
Function ListFilesPriv(ByVal fld As Scripting.folder, _
ByVal NestedDirs As Boolean) As String
Dim fil As Scripting.File
Dim subfld As Scripting.folder
' list all the files in this directory
For Each fil In fld.Files
'If UCase(Left(Dir(fil), 5)) = "MULTI" And fil.Type = "Microsoft Excel Worksheet" Then
If fil.Type = "Microsoft Excel Worksheet" Then
ListFilesPriv = ListFilesPriv & ";" & fil.Path
Debug.Print fil.Path
End If
Next
' if requested, search also subdirectories
If NestedDirs Then
For Each subfld In fld.SubFolders
ListFilesPriv = ListFilesPriv & ListFilesPriv(subfld, NestedDirs)
Next
End If
End Function
Finally . . .
Sub ListFiles()
Dim folder As Variant
Dim f As File
Dim fs As New FileSystemObject
Dim RowCtr As Integer
Dim FPath As String
Dim wb As Workbook
RowCtr = 1
FPath = "http://excel-pc:43231/Shared Documents"
For Each f In FPath
'Set folder = fs.GetFolder("C:\Users\Excel\Desktop\Ryan_Folder")
'For Each f In folder.Files
Cells(RowCtr, 1).Value = f.Name
RowCtr = RowCtr + 1
Next f
End Sub
Sub test()
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder("C:\Users\Excel\Desktop\Ryan_Folder")
'Set colSubfolders = objFolder.SubFolders
'For Each objSubfolder In colSubfolders
Cells(RowCtr, 1).Value = f.Name
RowCtr = RowCtr + 1
'Next
End Sub
Ryan Shuell -
VBA Autofilter state Excel 2010
I need to find out the state of a table column filter - especially dates. The new more complex filters in xl2010 cannot be found in Criteria1 or 2 - they stop macros as soon as you look at them if the operator is a list of values or any of the grouped
date filters. A recorded macro shows them being set via an array passed to the criteria but they don't seem available for viewing there.
Question - where did they put the multiple criteria values?Hi, Pennyowl,
Your experiments and table are amazing. I remembered I had been here a few months ago when I was searching something related to VBA. Now I am on the project on manipulating and restoring Excel AutoFilter state via VBA (and here I am visiting this site again).
Your table does inspire me to analyze and exploit more about this mystic-beast AutoFilter feature in Excel.
Here are some additional information you might find useful (if you are still playing with Excel VBA) or for other people as well:
- It's worth noticing (like you posted above) that for Filter object having Operator starting from 7 (xlFilterValues) and above, you may need non-basic variable to extract Criteria1. A Filter object with Operator >= 7 does not have Criteria2 as its property
or its trigger (except xlFilterValues that still accepts Criteria2 as its parameter - but beware of messy result if Criteria2 is used).
- For Operator 8 (xlFilterCellColor), you need an Interior object (Excel.Interior) to extract Criteria1. In case you need to execute this AutoFilter process via VBA, you need to pass a Long variable (Color) as Criteria1 and the xlFilterCellColor operator.
- For Operator 11 (xlFilterDynamic), you can extract the Criteria1 using basic Long variable. You can then execute this type of AutoFilter via VBA by using the same data you get from Criteria1. The enumeration for this value can be found in Object Browser,
using "XlDynamicFilterCriteria" keyword.
- For Operator 12 (xlFilterNoFill), you need an Interior object (Excel.Interior) to extract Criteria1. To execute this type of AutoFilter in VBA, you don't need anything passed as Criteria1 or Criteria2. Just pass the xlFilterNoFill as the Operator parameter
and it will be just fine.
- For date AutoFilter, especially in Excel 2010 (since I use this version), as far as I know (and as well as your posted above), there is no way of retrieving the Criteria1 value when you pick multiple values from the TreeView list while the ActiveWindow.AutoFilterDateGrouping
is set to True. The possible workaround is by setting that property to False, picking up the filter criterias again via UI and try extracting Criteria1 via code. Setting the property to false when the criterias has been populated will produce no effect. When
that property is set to False, the Criteria1 will be converted to mere strings, which can easily be grabbed at once using standard Variant variable.
In addition of your experiment table, I also created the table showing how the Macro Recorder reads when you record an AutoFilter process, what is inside the Watch Window when the AutoFilter is in effect, and how to replicate the AutoFilter process via VBA.
Here it is:
AutoFilter Operator
What Macro Recorder gives you
What is inside Watch Window
What you can do to mimic it via VBA
Operator
Value
Criteria1
Criteria2
Criteria1
Criteria2
Operator
Criteria1
Criteria2
Operator
Criteria1/Criteria2 Type
Remarks
xlAnd
1
String
[String]
Variant/String
[Variant/String]
xlAnd (or 0 if no Criteria2)
Required
Optional
Required
String
If Operator = 0, change it to xlAnd or xlOr to avoid error.
xlOr
2
String
[String]
Variant/String
[Variant/String]
xlOr (or 0 if no Criteria2)
Required
Optional
Required
String
If Operator = 0, change it to xlAnd or xlOr to avoid error.
xlTop10Items
3
String (n-th items from top/bottom)
N/A
Variant/String (e.g: ">=20")
N/A
xlTop10Items
Required
Do Not Use!
Do Not Use!
String
The Criteria1 should be like ">=20".
xlBottom10Items
4
String (n-th items from top/bottom)
N/A
Variant/String (e.g: ">=20")
N/A
xlBottom10Items
Required
Do Not Use!
Do Not Use!
String
The Criteria1 should be like ">=20".
xlTop10Percent
5
String (n-th percent from top/bottom)
N/A
Variant/String (e.g: ">=20")
N/A
xlTop10Percent
Required
Do Not Use!
Do Not Use!
String
The Criteria1 should be like ">=20".
xlBottom10Percent
6
String (n-th percent from top/bottom)
N/A
Variant/String (e.g: ">=20")
N/A
xlBottom10Percent
Required
Do Not Use!
Do Not Use!
String
The Criteria1 should be like ">=20".
xlFilterValues
7
String Array
[String Array]
Variant/String Array
[Variant/String Array]
xlFilterValues
Required
Optional
Required
String or String Array
Beware of messy result if Criteria2 is used.
xlFilterCellColor
8
Long (Color)
N/A
Variant/Interior
N/A
xlFilterCellColor
Required
Optional - No Use
Required
Long (Color)
N/A
xlFilterFontColor
9
Long (Color)
N/A
Variant/Long
N/A
xlFilterFontColor
Required
Optional - No Use
Required
Long (Color)
N/A
xlFilterIcon
10
Icon
N/A
Variant/Icon
N/A
xlFilterIcon
Required
Optional - No Use
Required
Icon
Very hard to mimic. Use CommandBar trick (control ID: 12235).
xlFilterDynamic
11
Long (XlDynamicFilterCriteria)
N/A
Variant/Long (XlDynamicFilterCriteria)
N/A
xlFilterDynamic
Required
Optional - No Use
Required
Long (XlDynamicFilterCriteria)
N/A
xlFilterNoFill
12
N/A
N/A
Variant/Interior
N/A
xlFilterNoFill
Optional - No Use
Optional - No Use
Required
Long (Color)
N/A
xlFilterAutomaticFontColor
13
N/A
N/A
Variant/Long
N/A
xlFilterAutomaticFontColor
Optional - No Use
Optional - No Use
Required
Long (Color)
N/A
xlFilterNoIcon
14
N/A
N/A
Variant/Empty
N/A
xlFilterNoIcon
Do Not Use!
Do Not Use!
Required
N/A
N/A
Legend
Meaning
Required
The parameter must be present to proceed.
Optional
The parameter is optional. If it is included, it wil be used as the filtering criteria.
Optional - No Use
The parameter is optional. Even if it is included, it will be ignored.
Do Not Use!
The parameter must not be present. If it is included, an error appears.
Hope this information useful for anyone looking for how AutoFilter works. Keep me informed of any updates.
Thanks and have a nice day. -
Can´t find my userform in Excel 2010
Hello to all!
I need help! I created a very big userform for a survey in an Excel 2010 worksheet. I created a small macro so it will load my userform. I created a new group in the Toolbar and added a button that called the macro. It worked great. I closed the worksheet,
closed my computer.
Today, I am opening my worksheet now and I do not find my userform! I click the button and it doesn´t work. I go to VBA and can´t find my userform. Please help!
Thank you.There was a VBA bug but it was fixed around SP2 time. It might have been after, so update with latest updates as well. In the men time I suspect you've lost your userform unless windows has kept a version in the background.
In Windows Explorer right click the file and select Properties. Check the previous versions tab.
With UserForms I've learnt to keep a copy in a file I never run. After updating I copy to another file to test :-(
Rod Gill
Author of the one and only Project VBA Book
www.project-systems.co.nz -
Create PDF Acrobat X Pro - does not display embedded excel 2010 tables in word 2010 properly
Hello,
I bought Acrobat X Pro and the first document I used 'Create PDF' on was a Word 2010 document with embedded (read linked) Excel 2010 tables.
When I opened the document after creating it the linked tables had a little arrow in the corner of a white box with a help text message of "click here to activate". The pdf is basically unusable.
Is there a setting to ensure that these embedded excel tables are created as normal tables - I do not want to have to keep pasting in tables/images into my Word documents when they are all updating automatically.
Thanks in advance for any help you can give me.
Regards,
CraigHello,
i am having exactly the same issue with Acrobat X Pro - with linked Excel 2010 tables in Word 2010.
Has there been a resolution to this eissue - it is potentially very time consuming to work around this issue for me.
I would post my files but I don't know how to attach them to the thread - only my second post .
Cheers,
slobbering_dog
This is the Word File - the table is an Excel 2010 spreadsheet linked (via Paste Special >Link) .
This is the resultant PDF file:
Thanks in advance - again !!
Message was edited by: slobbering_dog_72 -
I have a fairly large spreadsheet which creates layout floorplan maps based on a table of 3,000+ room locations and various cross-referenced attribute lookup tables which add flags & colour coding to the individual rooms. The maps also
include a few graphic elements beyond simple cells and borders, such as EMF images to indicate stairways, etc.
The sheet works perfectly on my Win7 desktop in Excel 2010:
However when loaded into Excel 2013 on my Win7 laptop, all of the images show as a red cross with the wording "This image cannot currently be displayed", thus:
Any ideas, as this looks like a bug in Excel 2013? Thanks.
AndreHi Andre,
What happens if you reimport the images from original source?
Try Running Excel Program firstly, and then open this file within Excel (File->Open).Also if you have Excel 2010 installed , try to open the file using Excel 2010, copy an paste the content to a blank Excel file.
You can also try to check the option 'Disable hardware graphics acceleration'. File->Options->Advanced ...
Wind Zhang
TechNet Community Support -
Sending and receivind ADC coefficients from/to soundcard in VBA for Excel 2010
How to send and receive ADC coefficients from/to soundcard(mixer,microphone) in VBA for Excel 2010 (noncom. edition, x64) to Excel macros for DFT (from IDFT), IIR , user defined samples parser (special
noise generator, graphic s(t),S(jw), arg s(jw) soundcard AFR test ) ?
What .dll is need for this (without bass.dll)?Example from internet :
'This project needs a module and a form
'The form must contain two labels, two progressbars, a timer and a checkbox
'Paste this code into the form
Dim hmixer As Long ' mixer handle
Dim inputVolCtrl As MIXERCONTROL ' waveout volume control
Dim outputVolCtrl As MIXERCONTROL ' microphone volume control
Dim rc As Long ' return code
Dim ok As Boolean ' boolean return code
Dim mxcd As MIXERCONTROLDETAILS ' control info
Dim vol As MIXERCONTROLDETAILS_SIGNED ' control's signed value
Dim volume As Long ' volume value
Dim volHmem As Long ' handle to volume memory
Private Sub Form_Load()
Me.ScaleMode = vbTwips
Me.Caption = "Volume meter"
Label1.Move 0, 0
Label1.AutoSize = True
Label1.Caption = "Input level"
Label2.Move 0, 4 * Label1.Height
Label2.AutoSize = True
Label2.Caption = "Output level"
ProgressBar1.Move Label1.Width * 2, 0, 3375
ProgressBar2.Move Label1.Width * 2, Label2.Top, 3375
Check1.Move ProgressBar1.Left, ProgressBar1.Height
Check1.Caption = "Get Input"
Me.Move Me.Left, Me.Top, ProgressBar1.Width + ProgressBar1.Left + 10 * Screen.TwipsPerPixelX, ProgressBar2.Top + ProgressBar2.Height + 30 * Screen.TwipsPerPixelY
Timer1.Interval = 50
Timer1.Enabled = True
' Open the mixer specified by DEVICEID
rc = mixerOpen(hmixer, DEVICEID, 0, 0, 0)
If ((MMSYSERR_NOERROR <> rc)) Then
MsgBox "Couldn't open the mixer."
Exit Sub
End If
' Get the input volume meter
ok = GetControl(hmixer, MIXERLINE_COMPONENTTYPE_DST_WAVEIN, MIXERCONTROL_CONTROLTYPE_PEAKMETER, inputVolCtrl)
If (ok <> True) Then
ok = GetControl(hmixer, MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE, MIXERCONTROL_CONTROLTYPE_PEAKMETER, inputVolCtrl)
End If
If (ok = True) Then
ProgressBar1.Min = 0
ProgressBar1.Max = inputVolCtrl.lMaximum
Else
ProgressBar1.Enabled = False
MsgBox "Couldn't get wavein meter"
End If
' Get the output volume meter
ok = GetControl(hmixer, MIXERLINE_COMPONENTTYPE_SRC_WAVEOUT, MIXERCONTROL_CONTROLTYPE_PEAKMETER, outputVolCtrl)
If (ok = True) Then
ProgressBar2.Min = 0
ProgressBar2.Max = outputVolCtrl.lMaximum
Else
ProgressBar2.Enabled = False
MsgBox "Couldn't get waveout meter"
End If
' Initialize mixercontrol structure
mxcd.cbStruct = Len(mxcd)
volHmem = GlobalAlloc(&H0, Len(volume)) ' Allocate a buffer for the volume value
mxcd.paDetails = GlobalLock(volHmem)
mxcd.cbDetails = Len(volume)
mxcd.cChannels = 1
End Sub
Private Sub Check1_Click()
If (Check1.Value = 1) Then
StartInput ' Start receiving audio input
Else
StopInput ' Stop receiving audio input
End If
End Sub
Private Sub Timer1_Timer()
On Error Resume Next
' Process sound buffer if recording
If (fRecording) Then
For i = 0 To (NUM_BUFFERS - 1)
If inHdr(i).dwFlags And WHDR_DONE Then
rc = waveInAddBuffer(hWaveIn, inHdr(i), Len(inHdr(i)))
End If
Next
End If
' Get the current input level
If (ProgressBar1.Enabled = True) Then
mxcd.dwControlID = inputVolCtrl.dwControlID
mxcd.item = inputVolCtrl.cMultipleItems
rc = mixerGetControlDetails(hmixer, mxcd, MIXER_GETCONTROLDETAILSF_VALUE)
CopyStructFromPtr volume, mxcd.paDetails, Len(volume)
If (volume < 0) Then
volume = -volume
End If
ProgressBar1.Value = volume
End If
' Get the current output level
If (ProgressBar2.Enabled = True) Then
mxcd.dwControlID = outputVolCtrl.dwControlID
mxcd.item = outputVolCtrl.cMultipleItems
rc = mixerGetControlDetails(hmixer, mxcd, MIXER_GETCONTROLDETAILSF_VALUE)
CopyStructFromPtr volume, mxcd.paDetails, Len(volume)
If (volume < 0) Then volume = -volume
ProgressBar2.Value = volume
End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
If (fRecording = True) Then
StopInput
End If
GlobalFree volHmem
End Sub
'Paste this code into the module
Public Const CALLBACK_FUNCTION = &H30000
Public Const MM_WIM_DATA = &H3C0
Public Const WHDR_DONE = &H1 ' done bit
Public Const GMEM_FIXED = &H0 ' Global Memory Flag used by GlobalAlloc functin
Type WAVEHDR
lpData As Long
dwBufferLength As Long
dwBytesRecorded As Long
dwUser As Long
dwFlags As Long
dwLoops As Long
lpNext As Long
Reserved As Long
End Type
Type WAVEINCAPS
wMid As Integer
wPid As Integer
vDriverVersion As Long
szPname As String * 32
dwFormats As Long
wChannels As Integer
End Type
Type WAVEFORMAT
wFormatTag As Integer
nChannels As Integer
nSamplesPerSec As Long
nAvgBytesPerSec As Long
nBlockAlign As Integer
wBitsPerSample As Integer
cbSize As Integer
End Type
Declare Function waveInOpen Lib "winmm.dll" (lphWaveIn As Long, ByVal uDeviceID As Long, lpFormat As WAVEFORMAT, ByVal dwCallback As Long, ByVal dwInstance As Long, ByVal dwFlags As Long) As Long
Declare Function waveInPrepareHeader Lib "winmm.dll" (ByVal hWaveIn As Long, lpWaveInHdr As WAVEHDR, ByVal uSize As Long) As Long
Declare Function waveInReset Lib "winmm.dll" (ByVal hWaveIn As Long) As Long
Declare Function waveInStart Lib "winmm.dll" (ByVal hWaveIn As Long) As Long
Declare Function waveInStop Lib "winmm.dll" (ByVal hWaveIn As Long) As Long
Declare Function waveInUnprepareHeader Lib "winmm.dll" (ByVal hWaveIn As Long, lpWaveInHdr As WAVEHDR, ByVal uSize As Long) As Long
Declare Function waveInClose Lib "winmm.dll" (ByVal hWaveIn As Long) As Long
Declare Function waveInGetDevCaps Lib "winmm.dll" Alias "waveInGetDevCapsA" (ByVal uDeviceID As Long, lpCaps As WAVEINCAPS, ByVal uSize As Long) As Long
Declare Function waveInGetNumDevs Lib "winmm.dll" () As Long
Declare Function waveInGetErrorText Lib "winmm.dll" Alias "waveInGetErrorTextA" (ByVal err As Long, ByVal lpText As String, ByVal uSize As Long) As Long
Declare Function waveInAddBuffer Lib "winmm.dll" (ByVal hWaveIn As Long, lpWaveInHdr As WAVEHDR, ByVal uSize As Long) As Long
Public Const MMSYSERR_NOERROR = 0
Public Const MAXPNAMELEN = 32
Public Const MIXER_LONG_NAME_CHARS = 64
Public Const MIXER_SHORT_NAME_CHARS = 16
Public Const MIXER_GETLINEINFOF_COMPONENTTYPE = &H3&
Public Const MIXER_GETCONTROLDETAILSF_VALUE = &H0&
Public Const MIXER_GETLINECONTROLSF_ONEBYTYPE = &H2&
Public Const MIXERLINE_COMPONENTTYPE_DST_FIRST = &H0&
Public Const MIXERLINE_COMPONENTTYPE_SRC_FIRST = &H1000&
Public Const MIXERLINE_COMPONENTTYPE_DST_SPEAKERS = (MIXERLINE_COMPONENTTYPE_DST_FIRST + 4)
Public Const MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE = (MIXERLINE_COMPONENTTYPE_SRC_FIRST + 3)
Public Const MIXERLINE_COMPONENTTYPE_SRC_LINE = (MIXERLINE_COMPONENTTYPE_SRC_FIRST + 2)
Public Const MIXERCONTROL_CT_CLASS_FADER = &H50000000
Public Const MIXERCONTROL_CT_UNITS_UNSIGNED = &H30000
Public Const MIXERCONTROL_CT_UNITS_SIGNED = &H20000
Public Const MIXERCONTROL_CT_CLASS_METER = &H10000000
Public Const MIXERCONTROL_CT_SC_METER_POLLED = &H0&
Public Const MIXERCONTROL_CONTROLTYPE_FADER = (MIXERCONTROL_CT_CLASS_FADER Or MIXERCONTROL_CT_UNITS_UNSIGNED)
Public Const MIXERCONTROL_CONTROLTYPE_VOLUME = (MIXERCONTROL_CONTROLTYPE_FADER + 1)
Public Const MIXERLINE_COMPONENTTYPE_DST_WAVEIN = (MIXERLINE_COMPONENTTYPE_DST_FIRST + 7)
Public Const MIXERLINE_COMPONENTTYPE_SRC_WAVEOUT = (MIXERLINE_COMPONENTTYPE_SRC_FIRST + 8)
Public Const MIXERCONTROL_CONTROLTYPE_SIGNEDMETER = (MIXERCONTROL_CT_CLASS_METER Or MIXERCONTROL_CT_SC_METER_POLLED Or MIXERCONTROL_CT_UNITS_SIGNED)
Public Const MIXERCONTROL_CONTROLTYPE_PEAKMETER = (MIXERCONTROL_CONTROLTYPE_SIGNEDMETER + 1)
Declare Function mixerClose Lib "winmm.dll" (ByVal hmx As Long) As Long
Declare Function mixerGetControlDetails Lib "winmm.dll" Alias "mixerGetControlDetailsA" (ByVal hmxobj As Long, pmxcd As MIXERCONTROLDETAILS, ByVal fdwDetails As Long) As Long
Declare Function mixerGetDevCaps Lib "winmm.dll" Alias "mixerGetDevCapsA" (ByVal uMxId As Long, ByVal pmxcaps As MIXERCAPS, ByVal cbmxcaps As Long) As Long
Declare Function mixerGetID Lib "winmm.dll" (ByVal hmxobj As Long, pumxID As Long, ByVal fdwId As Long) As Long
Declare Function mixerGetLineInfo Lib "winmm.dll" Alias "mixerGetLineInfoA" (ByVal hmxobj As Long, pmxl As MIXERLINE, ByVal fdwInfo As Long) As Long
Declare Function mixerGetLineControls Lib "winmm.dll" Alias "mixerGetLineControlsA" (ByVal hmxobj As Long, pmxlc As MIXERLINECONTROLS, ByVal fdwControls As Long) As Long
Declare Function mixerGetNumDevs Lib "winmm.dll" () As Long
Declare Function mixerMessage Lib "winmm.dll" (ByVal hmx As Long, ByVal uMsg As Long, ByVal dwParam1 As Long, ByVal dwParam2 As Long) As Long
Declare Function mixerOpen Lib "winmm.dll" (phmx As Long, ByVal uMxId As Long, ByVal dwCallback As Long, ByVal dwInstance As Long, ByVal fdwOpen As Long) As Long
Declare Function mixerSetControlDetails Lib "winmm.dll" (ByVal hmxobj As Long, pmxcd As MIXERCONTROLDETAILS, ByVal fdwDetails As Long) As Long
Declare Sub CopyStructFromPtr Lib "kernel32" Alias "RtlMoveMemory" (struct As Any, ByVal ptr As Long, ByVal cb As Long)
Declare Sub CopyPtrFromStruct Lib "kernel32" Alias "RtlMoveMemory" (ByVal ptr As Long, struct As Any, ByVal cb As Long)
Declare Function GlobalAlloc Lib "kernel32" (ByVal wFlags As Long, ByVal dwBytes As Long) As Long
Declare Function GlobalLock Lib "kernel32" (ByVal hmem As Long) As Long
Declare Function GlobalFree Lib "kernel32" (ByVal hmem As Long) As Long
Type MIXERCAPS
wMid As Integer
wPid As Integer
vDriverVersion As Long
szPname As String * MAXPNAMELEN
fdwSupport As Long
cDestinations As Long
End Type
Type MIXERCONTROL
cbStruct As Long
dwControlID As Long
dwControlType As Long
fdwControl As Long
cMultipleItems As Long
szShortName As String * MIXER_SHORT_NAME_CHARS
szName As String * MIXER_LONG_NAME_CHARS
lMinimum As Long
lMaximum As Long
Reserved(10) As Long
End Type
Type MIXERCONTROLDETAILS
cbStruct As Long
dwControlID As Long
cChannels As Long
item As Long
cbDetails As Long
paDetails As Long
End Type
Type MIXERCONTROLDETAILS_SIGNED
lValue As Long
End Type
Type MIXERLINE
cbStruct As Long
dwDestination As Long
dwSource As Long
dwLineID As Long
fdwLine As Long
dwUser As Long
dwComponentType As Long
cChannels As Long
cConnections As Long
cControls As Long
szShortName As String * MIXER_SHORT_NAME_CHARS
szName As String * MIXER_LONG_NAME_CHARS
dwType As Long
dwDeviceID As Long
wMid As Integer
wPid As Integer
vDriverVersion As Long
szPname As String * MAXPNAMELEN
End Type
Type MIXERLINECONTROLS
cbStruct As Long
dwLineID As Long
dwControl As Long
cControls As Long
cbmxctrl As Long
pamxctrl As Long
End Type
Public i As Integer, j As Integer, rc As Long, msg As String * 200, hWaveIn As Long
Public Const NUM_BUFFERS = 2
Public format As WAVEFORMAT, hmem(NUM_BUFFERS) As Long, inHdr(NUM_BUFFERS) As WAVEHDR
Public Const BUFFER_SIZE = 8192
Public Const DEVICEID = 0
Public fRecording As Boolean
Function GetControl(ByVal hmixer As Long, ByVal componentType As Long, ByVal ctrlType As Long, ByRef mxc As MIXERCONTROL) As Boolean
' This function attempts to obtain a mixer control. Returns True if successful.
Dim mxlc As MIXERLINECONTROLS
Dim mxl As MIXERLINE
Dim hmem As Long
Dim rc As Long
mxl.cbStruct = Len(mxl)
mxl.dwComponentType = componentType
' Obtain a line corresponding to the component type
rc = mixerGetLineInfo(hmixer, mxl, MIXER_GETLINEINFOF_COMPONENTTYPE)
If (MMSYSERR_NOERROR = rc) Then
mxlc.cbStruct = Len(mxlc)
mxlc.dwLineID = mxl.dwLineID
mxlc.dwControl = ctrlType
mxlc.cControls = 1
mxlc.cbmxctrl = Len(mxc)
' Allocate a buffer for the control
'hmem = GlobalAlloc(&H40, Len(mxc))
hmem = GlobalAlloc(GMEM_FIXED, Len(mxc))
mxlc.pamxctrl = GlobalLock(hmem)
mxc.cbStruct = Len(mxc)
' Get the control
rc = mixerGetLineControls(hmixer, mxlc, MIXER_GETLINECONTROLSF_ONEBYTYPE)
If (MMSYSERR_NOERROR = rc) Then
GetControl = True
' Copy the control into the destination structure
CopyStructFromPtr mxc, mxlc.pamxctrl, Len(mxc)
Else
GetControl = False
End If
GlobalFree (hmem)
Exit Function
End If
GetControl = False
End Function
' Function to process the wave recording notifications.
Sub waveInProc(ByVal hwi As Long, ByVal uMsg As Long, ByVal dwInstance As Long, ByRef hdr As WAVEHDR, ByVal dwParam2 As Long)
If (uMsg = MM_WIM_DATA) Then
If fRecording Then
rc = waveInAddBuffer(hwi, hdr, Len(hdr))
End If
End If
End Sub
' This function starts recording from the soundcard. The soundcard must be recording in order to
' monitor the input level. Without starting the recording from this application, input level
' can still be monitored if another application is recording audio
Function StartInput() As Boolean
If fRecording Then
StartInput = True
Exit Function
End If
format.wFormatTag = 1
format.nChannels = 1
format.wBitsPerSample = 8
format.nSamplesPerSec = 8000
format.nBlockAlign = format.nChannels * format.wBitsPerSample / 8
format.nAvgBytesPerSec = format.nSamplesPerSec * format.nBlockAlign
format.cbSize = 0
For i = 0 To NUM_BUFFERS - 1
hmem(i) = GlobalAlloc(&H40, BUFFER_SIZE)
inHdr(i).lpData = GlobalLock(hmem(i))
inHdr(i).dwBufferLength = BUFFER_SIZE
inHdr(i).dwFlags = 0
inHdr(i).dwLoops = 0
Next
rc = waveInOpen(hWaveIn, DEVICEID, format, 0, 0, 0)
If rc <> 0 Then
waveInGetErrorText rc, msg, Len(msg)
MsgBox msg
StartInput = False
Exit Function
End If
For i = 0 To NUM_BUFFERS - 1
rc = waveInPrepareHeader(hWaveIn, inHdr(i), Len(inHdr(i)))
If (rc <> 0) Then
waveInGetErrorText rc, msg, Len(msg)
MsgBox msg
End If
Next
For i = 0 To NUM_BUFFERS - 1
rc = waveInAddBuffer(hWaveIn, inHdr(i), Len(inHdr(i)))
If (rc <> 0) Then
waveInGetErrorText rc, msg, Len(msg)
MsgBox msg
End If
Next
fRecording = True
rc = waveInStart(hWaveIn)
StartInput = True
End Function
' Stop receiving audio input on the soundcard
Sub StopInput()
fRecording = False
waveInReset hWaveIn
waveInStop hWaveIn
For i = 0 To NUM_BUFFERS - 1
waveInUnprepareHeader hWaveIn, inHdr(i), Len(inHdr(i))
GlobalFree hmem(i)
Next
waveInClose hWaveIn
End Sub
Error if using winmm.dll, kernel32 in x64 mode -
SSRS 2012 export to Excel 2010 Via IE8 has many compatibility issues
Hi There,
We have many reports in SSRS 2012 which had originally developed in SSRS 2005. When ever we render these report into Excel we face two major issues;
First: After reports render in to Excel (xlsx) format, we have cell, column, row shifting problem and every element of the report is not in the same place as appose to 2005 render to xls format. Second.
for any drill through (link) report all the url will be blocked by Excel.
We use SSRS 2012, Office 2010 and IE 8. Also we don't want to add Export to Excel 2003 feature. In other word we want out put in xlsx.
Any solution, suggestion, hotfix is appreciatedHi Mercede,
According to your description, after you updated SSRS 2005 reports to SSRS 2012, reports render appose to 2005 when export them to Excel, and drill through link is blocked.
Question1:
A report definition file includes a reference to the RDL namespace that specifies the version of the report definition schema that is used to validate the .rdl file. After a report is upgraded locally or on the report server, you might notice additional errors,
warnings, and messages. This is the result of changes to the internal report object model and processing components, which cause messages to appear when underlying problems in the report are detected.
When you open an .rdl file in Report Designer in SQL Server Data Tools (SSDT), if the report was created for a previous namespace, Report Designer automatically creates a backup file and upgrades the report to the current namespace. This is the only way
you can upgrade a report definition file.
In order to improve the efficiency of troubleshooting, I need to ask several questions:
“we have cell, column, row shifting problem and every element of the report is not in the same place as appose to 2005 render to xls format” Could you please provide detailed information about the problem? I would be appreciated it if you could provide
a screenshot.
Did you update the reports by opening the .rdl files in SSDT?
Could you export report to Excel 2003 to see if it displays correctly?
This may be a lot of information to ask for at one time. However, by collecting this information now, it will help us move more quickly toward a solution.
Question2:
I tested the issue in my local machine, when we add drillthrough action to the report, if we select Go to report or Go to URL, the link works fine after we export report to excel. It failed to work when we use javascript:void window.open to open a URL in new
windows, the “window.open” can’t work in Excel because of the JavaScript protocol can work only with an exact page.
For more information about Upgrade Reports, please refer to the following document:
https://msdn.microsoft.com/en-us/library/ms143674(v=sql.110).aspx
If you have any more questions, please feel free to ask.
Thanks,
Wendy Fu
If you have any feedback on our support, please click
here.
Wendy Fu
TechNet Community Support
Hi Wendy,
Thank you much for your fast respond. And as for your questions:
1- Yes I did upgrade them by using SSDT tools in VS2012 and then deploy them again into our SSRS2012 report server.
2- For URLs and Hyperlinks, because the action is go to sub report, I used "Go To Report" and by look at content that been blocked by Excel, I have noticed that (Go To Report) action passes IP address of our SSRS Server . I don't know how can I change
it to use the actual path instead.
3- Shifting the Cells and Rows means when I export report (from SSRS 2005) to excel in xls format (Excel 2003 for example), has very same look as it shows in screen, but when I export it from ssrs 2012 to render it in to xlsx format (Excel 2010 in our case)
I face with merging cells and when I compare this xlsx out put with xls out put of very same report I have see the row that used to be on A23 for example now is in A20 or the column that used to be in A7 now is in B9 for example. And required a lot of manual
work on design to work with spaced between text boxes and location of each data region, and overlaps to get the same result. I want to know is there more efficient way to achieve the same out put as xls.
4- I can't export report to render in Excel 2003 (xls) format directly from SSRS server for we don't have that option in our export list, but I did "save it as" xls and faced the same Row, column, cell shifting as with xlsx.
Thank you so much
I am realistic, I expect miracles. -
SSAS tabular mode Perspective display in Excel 2010
Hello All,
I have SSAS tabular modal cube. I created one perspective based on user requirement. I am using Excel 2010 to open the perspective. When I check the Pivot Tbale Field List (window at the right), I can see all my tables, columns and mesaures that I selected
for my perspective by scrolling in hte Field List. However when I click the drop down which says (Show fields related to:) I can see only 3 to 4 Dimension tables and some of the measures that I selected. I don't see all the tables in that perspective. When
I open the perspective which contains the entire cube, I can see all tables, columns and measures in the drop down list, however with perspective it only shows certain table.
Does anyone why this behaviour in Excel. I tried opening in Excel 2013 but got same result.
Any help in solving this matter would be appreciated.
Thanks
Deepak GadaHi,
In tabular projects there is no property like "NameColumn" to change the display labels. What I would suggest is to create a calculated column in tabular project by using CONCATENATE() function available in DAX. As an example;
Account Names:= CONCATENATE([Account Name] + " - ", [Account ID])
Following is the link to CONCATENATE DAX function.
http://msdn.microsoft.com/en-us/library/ee634811.aspx
Best regards...
Maybe you are looking for
-
I bought a brand new iPhone 4 as soon as it came out which was 2010 I think. No problems until two weeks ago. I fractured the screen on it so I am slowly losiong some functions like charge, touch screen ability and need to activate my new iPhone bu
-
Calculation of Depreciation for Tax for India
Hi In India, there is a requirement that the Depreciation for Income Tax should be calculated based on the date of Acquisition. If an asset has been acquired before or on completion of 180 days of a Financial Year, than the calculation of Depreciatio
-
How to create Drop Down box in screen painter..??
Can anybody give me sample code or detailed description about creating Drop-Down Box in a screen...?? I have created the drop down box in screen.. But how to make data to be visible in Dropdown box, when i click the drop icon in that box...??? Regard
-
When I send a email, the people get it with my daughters email as the one who sent it. I have checked all the settings ...help
-
Forcing work stations to use proxy
I have an almost entirely MAC network using open directory. I am installing an Internet filter, K12USA SecureSchool. Is there a way to force all workstations to go through the "proxy" using a policy instead of having to go to each work station and co