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!

Similar Messages

  • Colors change in Excel 2010

    Hello,
    I am helping a customer that has a strange problem in Excel. Ill explain it by taking you through some steps.
    User opens Excel and creates a new file not based on any templates, just a standard new workbook.
    By using the standard theme (she is not changing themes) the user then changes the fill color of a cell. She picks a color from the theme colors section, but NOT from the top row. For example a light gray color from the leftmost column of colors.
    She saves the file in the standard file format (Excel Workbook (*.xlsx).
    She closes and reopens the file.
    Now the fill color of the cell has changed, and when checking what color it has changed to it is the color on the top row of that color column in the theme. In the above example of light grey it would open as white.
    We have not tested on all machines in the user environment, but everything points to that all users in that company is facing the same issues. So it seems to be an environmental thing as its unlikely that many users simultaniously are facing installation
    problems or the like.
    Any ideas?
    /Leyan

    Hi,
    Just checking in to see if the information was helpful. Please let us know if you would like further assistance.
    Thanks
    George Zhao
    Forum Support
    Come back and mark the replies as answers if they help and unmark them if they provide no help.
    If you have any feedback on our support, please click "[email protected]"

  • Compatibility of macros in Excel 2010

    Hi
    I have some excel 2007 files (having some macros) and want to use them in excel 2010. I want to open those excel 2007 files in excel 2010. Does my macros works in excel 2010.
    Can you please send some support documents.
    Regards
    Abhilesh

    Hi
    Thank you for using
    Microsoft Office for IT Professionals Forums.
    For backward compatibility with earlier versions of Excel, such as Excel 97-2003 or Excel 2007, you can use one of several ways to exchange workbooks between
    the different versions.
    Work in Compatibility Mode    You can open a workbook that was created
    in an earlier version of Excel and work in Compatibility Mode so that the workbook remains in a file format that can easily be opened again in the earlier version. Compatibility mode is not available for Excel 2007 workbooks.
    Download file converters    You can use file converters that you
    can download to open an Excel 2010 workbook in an earlier version of Excel.
    Check a workbook for compatibility    If you want to work in the
    current file format but have to share a workbook with people who use earlier versions of Excel, you can check that the data is compatible with earlier versions of Excel. You can then make the necessary changes to avoid the loss of data or fidelity that might
    occur when that workbook is opened in an earlier version of Excel.
    More detailed information you can refer to this article: Use Excel Starter 2010 with earlier versions of Excel
    http://office.microsoft.com/en-us/starter-help/use-excel-starter-2010-with-earlier-versions-of-excel-HA010387550.aspx?CTT=1
    Additional, you can read this article to learn more: Application Compatibility for Microsoft Office 2010
    http://blogs.technet.com/b/ptsblog/archive/2011/02/10/application-compatibility-for-microsoft-office-2010.aspx
    All compatibility areas are getting addressed by the full set of tools and programs:
    Feature-function change → Compatibility Inspector
    ISV applications → OEAT
    Add-in compatibility → OEAT
    Maintenance/migration of macros → Compatibility Inspector
    Maintenance/migration of scripts → Compatibility Inspector
    Document fidelity → OMPM
    Microsoft Office Code Compatibility Inspector user's guide
    http://technet.microsoft.com/en-us/library/ee833946.aspx
    Download:
    Office 2010 Tool: Compatibility Inspector
    http://www.microsoft.com/downloads/en/details.aspx?FamilyID=23c8a7f6-88b3-48ef-9710-9742340562c0&displaylang=en
    Changes in Excel 2010
    http://technet.microsoft.com/en-us/library/cc179167.aspx
    Please take your time to try the suggestions and let me know the results at your earliest convenience. If anything is unclear or if there is anything
    I can do for you, please feel free to let me know.
    Hope that helps.
    Sincerely
    William Zhou CHNPlease remember to mark the replies as answers if they help and unmark them if they provide no help.

  • 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!
    Mark

    Here 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

  • Excel VBA help: change resolution & compression settings programmatically

    Hello, I am looking for some VBA code to create a PDF from Excel (2010) but to first change the resolution and compression programmatically. My spreadsheet has an PNG format logo that requires turning the compression off, to keep it from pixelating. I am running Windows 7 and Acrobat 9 Pro  on my laptop, and Windows 8 and Acrobat X Pro on my PC, if that matters.
    I've been hoping to find something on the internet I could just copy & paste for my spreadsheets but have not found anything so far. I have found some VBA for some non-Acrobat products, but consider that a last resort, since I am already using Acrobat Pro. I am not asking anyone to write anything for me, but hopefully you can point me in the right direction, please, with some links or copying of your own!

    You don't have direct programmatic access to these settings.
    But each setting is included in a job options file and you CAN choose the job option to use when running Distiller.
    Basic method:
    1. print to file using the Adobe PDF printer (standard Excel or Windows techniques). This will make a PostScript file.
    2. run Distiller to convert the PostScript to PDF, with your selected job options. This is described in the SDK.
    Important note: the result will be like what you get when printing to PDF. Check this is suitable. You cannot do this, so far as I can see, like the Create PDF button/menu item with its extra features you might wish for.

  • 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, theShyButterfly

    I 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.

  • Running Excel VBA code developed in Office 2010 under office 2013

    I have developed a large application successfully under Excel 2010 and I have a 30 day trial of office 2013. My applications will not run. However if I take a piece of code from the application and open a new spreadsheet under 2013 and place it in a sub
    and then run it ...works fine. So code that runs perfectly in an office 2010 environment will not run in the 2013 environment. I have changed the macro security settings to the most liberal and set the "trust VBA object model" option...still won't
    work. I know its not the code because I can insert it in a new sheet and run it. PLEASE HELP 

    Hello Roderick,
    It is not clear whether the code is working or not...+
    > However if I take a piece of code from the application and open a new spreadsheet under 2013 and place it in a sub and then run it ...works fine. So code that runs perfectly in an office 2010 environment will not run in the 2013 environment.
    I see the following statements:
    > and then run it ...works fine
    and then you wrote the opposite:
    > will not run in the 2013 environment
    Can you run the code under the debugger? Does it work in Office 2013?
    It looks like some of your event handlers are not fired. Am I right?

  • 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.

  • Excel 2010 changes relative link paths to absolute in files synced with Offline Files in Windows 7

    Hello! I'm wondering if anyone else has seen this problem: I have a large number of Excel 2010 and 2003 files in a folder on my file server. This whole folder is also synced to my computer using Offline Files in Windows 7. I have a lot of references between
    cells in different Excel files, and all referenced workbooks are physically in the same folder. This all works nicely when I create these files at work - all file paths referenced in the cells are created as relative paths and the documents open correctly.
    This is, I understand, the expected and default behavior when Excel creates links. When I edit these files at home, nothing seems odd until I get back to work and sync these files back to the file server. At this point, I discovered that Excel 2010 has, when
    I saved the files while away from the corporate network, changed /all/ the cell references in any offline-edited Excel files to point at absolute paths, and that these absolute paths point to somewhere in my %APPDATA% structure. So whenever I come to work
    and I try to open an Excel file that I have recently worked with offline, I get a bunch of error messages about referenced files that are missing, although clearly they exist in the same folder as the file I've opened, and I must edit all the file references
    again, whereupon they are again created correctly as relative paths (since all files exist in the same folder), which are promptly mangled into absolute C:\....\Offline Files\.....\..... paths whenever I save them at home (and since that works too, I don't
    notice it again until I come back to work and the offline files are synced back to the real network location). This seems to be a case of Windows 7's Offline Files not being able to fool Excel 2010 into believing it is working on a file server - apparently
    Excel 2010 can see through the fakery and decides on it's own to "fix" the problem (which obviously isn't a problem since the paths are relative to begin with) by saving the paths as absolute paths instead. Yes, really clever, Excel. The exepected behavior
    according to MSKB is that links are created as relative paths, so why does it change to absolute whenever Offline Files are involved? I know Offline Files only syncs, it doesn't actually change the files, so I can conclude that Excel is the program at fault
    here. Is there a fix for this, or a known workaround? Because frankly, this bug makes it impossible for me to work in any advanced manner with linked Excel files. The sad thing is that this worked perfectly fine with Office 2003 and Windows XP. Is there a
    patch for this problem that I might have missed (I am running the latest Service Pack and I get Office updates from Microsoft Update). If not, is there a workaround I can use to prevent Excel from corrupting my links when I edit the files offline?

    Hello danceswithwindows,
    Thank you for your post.
    This is a quick note to let you know that we are performing research on this issue.
    Sincerely
    Rex Zhang
    Rex Zhang
    TechNet Community Support

  • Switch Linked (xl source) Tables - behavior change Excel 2010 PP vs. Excel 2013 PP -- In 2013 all calcs of table are lost

    Situation:
    PowerPivot 2010 Model based on 10 linked tables (this tables are generated and refreshed as needed by SQL 2012 MDS Excel-AddIn)
    Unfortunately Excel MDS AddIn changes sometimes the tablename (case: MDS Add-In Filter changed, MDS Server changed). So after Change of tablename we have to fix the powerpivot link to this Excel tables in powerpivot to get powerpivot refresh working again
    Problem:
    With Excel 2010 PowerPivot this was possible without big Problems. As Long as table has identical structure one can Change/Switch the table in powerpivot Windows > Ribbon "Linked" Table > DropDown "Linked Table X" or during update
    via Dialog "Errors in Linked Table"
    After upgrading the solution to Excel 2013 this is not possible any more without loosing any column- or measure calcs defined for this table! :( Every time you Change the assigned Excel table for an existing linked powerpivot table..you
    get following Dialog:
    "You are changing the source of X to Excel table Y. Changing the source will remove all formatting, measures, KPIs, hierarchies, and other Settings applied to the table. Are you sure you want to to continute?"
    Does anyone found a Workaround for persisting existing calc of linked tables when changing the sourcetable (to another Excel table with same structure)??
    Dear MS, this is IMHO really a step backwards and blocks the migration of our existing Excel 2010 PowerPivot Solution? Should i create a connect entry for that?!
    Version-Info:
    2010 Version: 11.0.3000.0 (PP Ribbon>Settings)
    2013 Version: 11.0.2809.81 (Product version displayed for dll c:\program files\Microsoft Office\Office15\Addins\PowerPivot excel Add-In\PowerPivotExcelClientAddIn.dll)

    There is a very similar issue discussed here where i tried to show the different behavior in terms of linked tables in Excel/PowerPivot 2010 vs 2013
    http://social.technet.microsoft.com/Forums/en-US/8fd927f7-30fd-49b7-809c-cb1414955638/linked-tables-excel-2013-vs-2010-difference?forum=sqlkjpowerpivotforexcel
    maybe it helps you to understand the issue
    I assume that MDS creates a new table every time you refresh it thereby breaking the link to PowerPivot
    in case you only have calculated measure you may created a separate, independent linked table and define all calculated measures there
    this way they at least would not get removed
    hth,
    gerhard
    Gerhard Brueckl
    blogging @ http://blog.gbrueckl.at
    working @ http://www.pmOne.com

  • 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 &lt;&gt; 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 &lt;&gt; 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(&amp;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 &lt; 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 &lt; 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 = &amp;H30000
    Public Const MM_WIM_DATA = &amp;H3C0
    Public Const WHDR_DONE = &amp;H1 ' done bit
    Public Const GMEM_FIXED = &amp;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 = &amp;H3&amp;
    Public Const MIXER_GETCONTROLDETAILSF_VALUE = &amp;H0&amp;
    Public Const MIXER_GETLINECONTROLSF_ONEBYTYPE = &amp;H2&amp;
    Public Const MIXERLINE_COMPONENTTYPE_DST_FIRST = &amp;H0&amp;
    Public Const MIXERLINE_COMPONENTTYPE_SRC_FIRST = &amp;H1000&amp;
    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 = &amp;H50000000
    Public Const MIXERCONTROL_CT_UNITS_UNSIGNED = &amp;H30000
    Public Const MIXERCONTROL_CT_UNITS_SIGNED = &amp;H20000
    Public Const MIXERCONTROL_CT_CLASS_METER = &amp;H10000000
    Public Const MIXERCONTROL_CT_SC_METER_POLLED = &amp;H0&amp;
    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(&amp;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(&amp;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 &lt;&gt; 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 &lt;&gt; 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 &lt;&gt; 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 

  • Excel 2010 bug -- cannot place controls on chart properly after changing paper size

    I have encountered unexpected behavior in Excel 2010 when placing controls on a chart that is a separate sheet. The issue is that the controls (e.g. spinner, scroll bar, etc.) cannot be placed or moved to the right side or the bottom.
    Steps to reproduce:
    1) create a chart as a separate sheet
    2) change the paper size to, for example, A6 (4.13" x 5.83")
    3) change paper size back to Letter (8.5" x 11")
    4) controls cannot be placed on right side or bottom of chart.
    It appears that instead of using the current dimensions of the chart paper size to determine where controls may be placed, the smallest dimensions that have ever been applied to the chart are used.
    I am looking for a workaround for this issue since I would like to use a paper size large than 8.5" x 11", but I cannot place controls on such a chart properly at this time.
    Any ideas?

    I have found a workaround for this issue:
    1) change paper size in your default printer's preferences to the paper size you want in Excel.
    2) afterwards insert or create the chart. It is automatically the correct paper size, and controls can be placed or moved properly.
    3) change default printer paper size back.
    In case your chart has already been created, simply copy the existing chart in step 2 instead of inserting/creating.
    Aidan
    Edit: credit to http://webdesignerpark.blogspot.com/2013/02/paper-size-to-set-your-default-paper.htmlfor the idea on changing default paper size.

  • Cell/Background color changes when copying to other Excel 2010 document

    When you copy and paste report cells (e.g. CO report outputted in Office integration, MS Excel) to a new Excel file, the background color changed dramatically (to bright red).
    SAP Theme:  SAP Signature Theme
    Excel 2010
    We tried paste option > match destination formatting but does not help.
    Anyone has similiar problems?  Appreciate any help.

    dear friend,
    you would do:
    1. search SAP Notes;
    2. check out the updates/patches for your MS Office;
    3. replicate it on another computer/another sap user (make sure it is a local issue)
    good luck!

  • Changing worksheet names in excel 2010

    I recently switched from excel 2003 to 2010 usnig Oralce BI Add In
    In 2003 I could change the names of the Worksheets and it would not cause an issue with the Oracle BI queries
    In Excel 2010 if I change the name of a worksheet after I have created a query, then Oracle BI no longer recognizes the query as being on the Tab with the new name
    Is there a way to change the TAB/Worksheet name with out it impacting the Oracle BI Query?
    Thanks
    PerryK

    Hello Lori,
    I think that is possible :) one question - you want to merge those two worksheets into one pivottable report? That would be little more complicated.
    If not, just try to put all your wanted columns into pivottable "row field" part - Excel won't treat the data as a calculation and will just display according to outline. One nice tip - you can always change the report layout from "compact
    form" into "tabular form" (using - PivotTable Tools/Design/Report Layout). That would display the data in separate columns so you can filter easily.
    Let me know, if it works :)
    Milan

  • Change Middle Names to Middle Initials in Excel 2010

    In Excel 2010, is there a way to convert "John Walker Smith" to "John W Smith"?
    I wish to use a formula instead of VBA code fixes please.
    Doug in York PA
    Douglas R. Eckert

    Let's say that 'John Walker Smith' is in A1.
    In B1, enter the formula
    =IFERROR(LEFT(A1,FIND(" ",A1)+1)&RIGHT(A1,LEN(A1)-FIND(" ",A1,FIND(" ",A1)+1)+1),A1)
    This formula can be filled down.
    It will work OK if there is a suffix such as Jr or Ph.D. ('John Walker Smith, Ph.D.') or if there is no middle name ('Johnny Walker'), but it will fail if there is a suffix and no middle name: 'James Smith, Jr' will become 'James S Jr'.
    Regards, Hans Vogelaar (http://www.eileenslounge.com)

Maybe you are looking for