How do I hide a table in Word using VB or VBA

See

http://social.msdn.microsoft.com/Forums/en-US/worddev/thread/3ce3285e-0993-4d82-9d9f-eac30a18e4a6/

MyTable.Range.Font.Hidden = True

or

With ActiveDocument.Tables(1).Range.Font
.Hidden = Not .Hidden
End With

Be careful there are options in word to show/print hidden items.
In Word 2003 see Tools > Options > Print > Section “Include with Document” for option “Hidden Text”

Also Show/Hide mark up will show the table for developers.

 

Unable to apply publish properties for item “ApplicationCode\SystemNames.xml”

Solved with thanks to:

http://stackoverflow.com/questions/9284375/unable-to-apply-publish-properties-for-item-x

“It appears that the issue is related to ClickOnce. Navigate to the project, right click on it and click on properties. Go to the Publish tab and click on Application Files. Check the ‘Show all files’ checkbox and scroll through the list of files. Eventually, you will come across the file that has a yellow exclamation point on it. This file is orphaned and needs to be removed. Right click on the file and there should be a remove option.

Now build the solution and the warning should be gone.”

Visual Studio unable to copy file because it is being used by another process

 

To try and get around this I closed VS and re-opened it. Still the same problem. In this scenario I then closed it again and on inspection of Task Manager I found that devenv was still running as a process (it was not in Applications). After Killing this extra devenv my computer blue screened. After restarting itself I was able to open my solution and build.

How do I use Refelection to get names and values of an object

 

Function GetWODataAsMessage(WO AsInteger) AsString

‘#1446
SetContext()

Dim result = (From w In context.WorkOrders Where w.WO = WO Select w).FirstOrDefault

If result IsNothing Then

Return String.Concat(“WO, “, WO, ” was not found”)

EndIf

Dim msg = String.Concat(“Information for W-“, WO)

ForEach prop In result.GetType().GetProperties

If prop.CanRead Then

SelectCase prop.PropertyType

CaseGetType(Byte()), GetType(Business.EBC.EntityModel.Product)

‘Do Nothing

‘Case GetType(Business.EBC.EntityModel.Product)

‘ ‘Do Nothing

Case Else

Dim Tabs = String.Concat(vbTab, vbTab)

If prop.Name.Length < 4 Then

Tabs = String.Concat(vbTab, vbTab, vbTab)

ElseIf prop.Name.Length > 16 Then

Tabs = vbTab

EndIf

‘, prop.PropertyType ‘Testing only

msg = String.Concat(msg, vbCrLf, prop.Name, Tabs, prop.GetValue(result, Nothing))

End Select

EndIf

Next

Return msg

End Function

How to store data with XML

  1. One option is to set-up a dataset
  2. Add a manual table and columns.
  3. Add XML file
  4. See first two lines here

<?xml version=”1.0″ standalone=”yes”?>
<dsSystemNames xmlns=”http://tempuri.org/dsSystemNames.xsd”&gt;
<SystemNames>
<ID>1</ID>
<SystemName>Fred</SystemName>
<DateInput>2012-08-09T10:45:00</DateInput>
</SystemNames>
</dsSystemNames>

  1. It is very fussy about format. For instance DateTime format must have T and full time down to hundreths of a second

Could not load file or assembly … or one of its dependencies. The module was expected to contain

Possibly the reference is an executable program. Solution is:

  1. Right-click on project not building properly – Project Build Order
  2. Check that the reference is higher in the list
  3. If not then use Dependencies tab to add the required dependency which changes the Build Order

Similar to http://wp.me/p17IS4-dh

 

Entity Framework – Inheritance/Association – including Troubleshooting and comment on verbose SQL

See this video on Model Table Per Type

http://msdn.microsoft.com/en-us/data/cc765425.aspx

  1. Update Model from Database – Add Table
  2. Right-click Entity Add Inheritance
  3. Error 11009: Property ‘<>’ is not mapped
  4. Right-click Entity > Table Mapping > re map missing
  5. Running transformation: A member named ID cannot be defined in class DerivedClass. It is defined in ancestor class ParentClass.
  6. Delete it from DerivedClass

Error 3027: No mapping specified for the following EntitySet/AssociationSet – TableATableB

Error 11008: Association TableATableB is not mapped
EF is not expecting both a Foreign Key relationship and an association, see note at top of: http://msdn.microsoft.com/en-us/library/bb738488.aspx
Delete the association

Existing queries may then break as the Entity type no longer exists. So in my case Products is base type PadMain inherits from this. Used to have PadMains now PadMain EntityName is Products, so query on PadMains needs to change. From/To:

From b In context.PadMains
From b in context.Products1.OfType(Of PadMain)()

However if PadMain has subtypes then the SQL generated is verbose. If table is separated out in SQL then you just want the base table. If a field will appear in multiple related child tables then you will get duplications. In this scenario this is a major disadvantage of Entity Framework. Hopefully it will be fixed in future. For now I have removed my inheritance.

TFS Preview

I am on my way:

I have set up my account. Created a project. Created users. Download HotFix for VS2010. Connected to TFS from VS2010 on my machine. Added a solution and one project. Created a user story. Checked in the code. Created a build on my machine which is stored on TFS Preview. Started a new build. Build completed OK.

The only thing that has not worked is Home > Activities > “Open new instance of Visual Studio”. Perhaps this only works with VS2012.

Visual Studio Tips

 

  1. If at the bottom of a region you may think you need to go to the top before you can collapse the region. You can actually double-click the line just to the left of the code to collapse it. This is very subtle.

The file or directory is corrupt and non-readable. (possibly in Visual Studio and TFS Build broke)

Problem found

<drive>:\<folder> is not accessible    The file or directory is corrupt and non-readable.The file or directory is corrupt and non-readable. The file or directory \<folder> is corrupt and unreadable.    Please Run the Chkdsk utility.

Was causing build to fail. Some how system had created a badly named file RoqteOpsData where the q should have been a u

Resolution

http://support.microsoft.com/kb/176646

Attempt to repair the damaged file, folder or file system index using Chkdsk. To do so, follow these steps:

  1. Click Start, and then click Run.
  2. In the Open box, type chkdsk /f <drive>:,   where <drive> is the letter of the drive on which the damaged file,   folder or file system index exists.
  3. Click OK.